|
|
2 |- \+ K7 n1 U1 P6 j- `9 F! t
行,这个怎么样& l) }! r! z" a4 C5 \
- package com.xhg78999.mtrfac.render;
: M$ v. h% _1 c$ w1 H% t( Z
5 V+ B9 O7 A/ A5 l! N0 Z- import com.mojang.blaze3d.vertex.PoseStack;
8 ~7 [+ f! }; ]) T, s3 U - import com.mojang.blaze3d.vertex.VertexConsumer; b5 k: g. u$ f
- import net.minecraft.client.renderer.RenderType;
; j+ H8 I0 h% Y- q5 \1 j - import net.minecraft.resources.ResourceLocation;& U7 c" r M0 ~6 Y6 B8 X
7 q' z7 T% c+ n- import java.util.*;: b" T0 O# m$ h
2 L2 X! w6 h% K; n/ x( T- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
, y, c6 p4 S% P- q: A
7 }; R6 }9 F6 p: ]: f+ L' A- public class LineRender{9 l2 ? D) [. s( N
- private final PoseStack pose;
& Z3 t* v9 s3 n. |; h - private final MultiBufferSource source;
: V$ y1 O" W; U - private static final Map<String, RenderType> CACHE_A = new HashMap<>();) v1 j, R5 }: z1 ]: B3 t1 y1 j6 B: |+ G) \
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();! z& D# a5 g0 M
4 Q- _$ h; t" C- 8 x2 `5 `4 p: E" b: B0 _5 E
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){3 i. p! w& p& Q5 u; }& Y
- if(x1 == x2 && y1 == y2 && z1 == z2){+ ~2 x. h7 q$ H0 T5 K) m
- return;
/ x; p6 T |: b; A( k - }
0 ~( B* { @- T - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){6 I1 M% s; G; Z+ Q9 F: h$ g
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");. w8 I5 B. T5 E. o* X! a# ]
- }
1 v0 n# d; q3 w; v3 F! { - pose.pushPose();, T- c R6 P3 |; I9 F, ?* G9 M' @
- final int newLight = convertLight(6);4 A5 d" q# ]( Y1 e1 n$ Y1 i) X
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));4 |0 @1 K% A1 H, w# e' L0 w
- final float lineHeightSmall = (y2 - y1);/ ]5 h, _) E0 G5 i4 X9 V( s
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);3 x, p' C7 g2 u# z& k
- pose.popPose();) n9 ]5 f3 X) T
- }
* c' _; b+ I% G( ?2 z
, _7 i- _- `. O# e- private RenderType getLayers(String texture, int light) { O2 `/ k e, `, p- |
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));+ X* q4 k/ _* V1 g
- }# G G. n( w4 o9 W
\" n( h" u: }# [- T- private RenderType getLightTexture(ResourceLocation texture) {4 j: d, k% v+ N: `: v% {
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
6 H* ]4 H9 ?/ O v - }0 U' R1 Y! k% x6 \* Z
- 4 s, `8 Z, X f+ h4 R4 A9 X }% H5 _
- private RenderType getTexture(ResourceLocation texture) {& D. P% W3 o- h# N( m6 [
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);# k( O" B& j3 Q: |) O3 h0 s
- }
/ S @/ Q+ ^! F4 Z, q - * t0 q! ~$ Z! v* }' F
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {5 y' u/ c' N0 t; l6 L8 m
- if (cache.containsKey(identifier)) {
9 X7 W4 a/ I! }+ @* y! b - return cache.get(identifier);: h" p+ L! }$ n, f( F3 v0 u! A
- } else {7 o- W2 i2 A* O! z( i' q' S
- final RenderType renderLayer = supplier.get();0 a `, ^/ c( W6 z8 }3 f9 w
- cache.put(identifier, renderLayer);& T& o+ ?8 O& s1 g% o* z$ L0 O4 \
- return renderLayer;& j7 J; \) }3 _* t# |' Q& E& X
- }
9 m1 D6 o7 c* Z1 @3 K, M$ o - }: O; |0 g$ k5 g! Y: k
- }
复制代码 |
|