|
|
) [6 Y6 q, T9 Y$ {行,这个怎么样
# t" ?: f; i6 }4 s1 k- package com.xhg78999.mtrfac.render;" L" a0 g7 j6 w& R
/ k+ p. `$ r: f" N5 W5 `- import com.mojang.blaze3d.vertex.PoseStack;
; p* T& f- q p$ F! q7 ~4 ]: p - import com.mojang.blaze3d.vertex.VertexConsumer;2 F: F6 _' u( n& I5 p! ?2 m
- import net.minecraft.client.renderer.RenderType;) i' Z) u7 b9 C( E" d
- import net.minecraft.resources.ResourceLocation;
. p. K8 y1 ]7 O
/ B; O3 V2 w( f9 ]- import java.util.*;% {# |5 U! i) l9 \1 m# B
- 5 T( o- P+ } X4 c3 Q' A5 N
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(6 b2 |" r( [' _, D) S$ A: ^* b
# U! U( [: [* [* ]- public class LineRender{# q$ o$ r* C$ j3 u: B" `' ^* p
- private final PoseStack pose;
! u- t! S4 e% H: F$ G6 D - private final MultiBufferSource source;: q% G4 r8 n. Q, [- Y
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
+ J) C8 O9 x6 G" Q* r - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();2 Z- \8 H6 {: @
5 x% T) h7 O8 ]4 i9 r$ z0 e
; O" |1 D/ a& [" t" `4 u- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
& Z( V8 S8 W/ \% r. I - if(x1 == x2 && y1 == y2 && z1 == z2){
9 m2 V/ n. v7 ^$ v& l - return;4 s; q+ h( n1 @2 z2 C
- }) h7 A5 m; N. s! z, v4 u
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){3 [: Z0 x$ C9 `. S6 A; f
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");9 A9 {9 U0 ?4 l- H. K& I
- }
( W* J g0 z6 Y2 y - pose.pushPose();4 y( X* y g+ g" J
- final int newLight = convertLight(6);
$ ]( e4 n* Y& S - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
0 {6 P% G2 Q5 ~, N- [1 I# n9 G - final float lineHeightSmall = (y2 - y1);
& ]; \7 D' J: p: G, S5 W - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);# n- N: y2 P/ y+ H0 ^
- pose.popPose();4 V6 a8 s& A1 t' J- `$ g
- }& m1 Z7 O$ e2 k& w, I, v' c( k
- , m0 n* Z/ \+ K) N3 i' X, U
- private RenderType getLayers(String texture, int light) {
* _+ z* T! c) P# i4 f4 H - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));! a& O4 h) @* u
- }1 w. o$ x2 I V5 h' p
- ) }0 P/ U) [3 e
- private RenderType getLightTexture(ResourceLocation texture) {5 Y" z0 t1 F E* w
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);; t/ x! v/ @& `4 V, X
- }
& @( h, y) Y3 Z# ]2 r) V0 `4 C5 K+ d$ Q - 8 |9 G: k: n# U: O
- private RenderType getTexture(ResourceLocation texture) {, f7 {0 [7 V% B$ _- B* r
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);& e6 z8 a" @1 i
- }
3 g4 |# Q# H+ E% U - " x5 W/ l; \( ^% P4 W
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
! A8 I# V! N; z& K9 f5 H+ j - if (cache.containsKey(identifier)) {
' x ?) ` t0 g2 ~ - return cache.get(identifier);. w9 W4 E! ~3 I6 S2 ]2 M
- } else {
" ^; l7 z8 f9 c/ J C - final RenderType renderLayer = supplier.get();5 m) {( v8 l y
- cache.put(identifier, renderLayer);
. p J x2 Q6 O- q) o - return renderLayer;7 \+ n$ h7 w2 ^, y3 m
- }! s; C. \% N3 V b4 {2 x
- }
" S2 b9 I5 J2 X+ T+ A& x0 S - }
复制代码 |
|