| 
 | 
 
2 e7 s% w: T" X* p% d行,这个怎么样 
+ W; V; T) a' P- package com.xhg78999.mtrfac.render;! T1 H4 `8 G( m. G4 L
 
  
) z0 S: o2 V$ a" w- import com.mojang.blaze3d.vertex.PoseStack;
 
1 @: @, A8 |4 r8 E% Q - import com.mojang.blaze3d.vertex.VertexConsumer;
 
0 d- C. n$ F3 G# | - import net.minecraft.client.renderer.RenderType;) a8 c9 L/ F7 M9 O5 l$ r. A/ q
 
 - import net.minecraft.resources.ResourceLocation;' H0 [* G5 m$ n+ n& ]7 G* j
 
  
: q- T1 V  C7 _+ P- import java.util.*;, [/ r6 W$ U" g2 l' b, {( _7 L
 
 - 2 }+ l8 r: i) N4 R) D; Q
 
 - // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
 
. n7 [+ a3 a$ N' S- X) C* n - 7 p9 ?- p1 y; `1 S/ g3 q
 
 - public class LineRender{
 
( T, W/ h& R% s  T' _8 I -     private final PoseStack pose;- Q) D8 N$ E! ]3 `/ v) \. @
 
 -     private final MultiBufferSource source;
 
% S' S4 n, `7 }& N -     private static final Map<String, RenderType> CACHE_A = new HashMap<>();; L/ ~* r& k6 l. b- I
 
 -     private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
 
3 u. @# g* v6 Y* }- V+ b7 @ - - M% U) |+ ^) |$ n
 
 - & ]! s( ~' |$ p* v9 ]. u
 
 -     public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
 
- p: W7 ?2 w  z8 ?* ~ -         if(x1 == x2 && y1 == y2 && z1 == z2){( m7 e, B1 O# P
 
 -             return;- ?5 E; A7 a7 d! x
 
 -         }3 c4 G' s  I9 d% N+ g6 C! q
 
 -         if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
 
6 N, f- {6 b7 v: i+ g4 z7 I4 H -             System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
 
9 d+ ~" j/ |+ D, ?# A  Z -         }, Z5 l' @& j' d+ x; c: E+ U( K! C
 
 -         pose.pushPose();6 Y/ d3 s0 @5 c! P# [0 a3 _' b
 
 -                 final int newLight = convertLight(6);% S9 d" X) |% {
 
 -                 final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
 
* x5 Y2 p6 z' \# }; ] -                 final float lineHeightSmall = (y2 - y1);% d: d! X0 J! |9 K( Q# Q
 
 -                 this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);3 I; `- d. N7 p7 t% K
 
 -                 pose.popPose();
 
# u2 c9 I  L0 Y2 _2 l -     }( z3 l- r" ]+ B
 
 - , F/ P, a' L1 J' J9 O6 f6 ]7 P- V
 
 -     private RenderType getLayers(String texture, int light) {" [' s- a2 j% J0 h; a/ f7 P* c
 
 -                 return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));! E1 Y3 |2 i; w* _9 H
 
 -         }
 
9 b- z' W" u0 G  
# o+ o+ C1 ~, `  w5 {  M6 R3 M-     private RenderType getLightTexture(ResourceLocation texture) {
 
# G, p, n. d, w% z8 w/ _ -                 return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);/ r3 g+ ]# d8 C: J' \" k, W, ~
 
 -         }
 
: p" Z8 H) q" n" e1 e' S - 9 @& U* ]! H9 `. c4 C
 
 -     private RenderType getTexture(ResourceLocation texture) {
 
9 B  x" N4 p0 ?) E7 M -                 return this.cache(texture, () -> entityCutout(texture), CACHE_B);
 
! h+ D# ?9 X' a5 ~' y- I -         }8 A- G+ v; d$ l. k8 ?+ g& _
 
 - ( M4 }- D+ U7 F2 P# k$ n. D
 
 -     private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
 
  o& n) _9 s$ o' D+ a -                 if (cache.containsKey(identifier)) {
 
  N) m/ b( @1 z4 O& q/ M -                         return cache.get(identifier);
 
' L, {. X3 ?9 u -                 } else {
 
2 ?. O. X1 G8 N9 s& N3 m& m' E* W -                         final RenderType renderLayer = supplier.get();
 
: M# Z% I6 W9 F  c' U -                         cache.put(identifier, renderLayer);
 
  R* a* _& @% I! H5 v- ]  ?( j -                         return renderLayer;
 
6 @* ]1 _6 S+ h0 d0 X -                 }
 
+ ^. R$ U8 Q4 O) @ -         }
 
* E) s- y. L6 f: C6 I) ^ - }
 
  复制代码 |   
 
 
 
 |