|
|
: H. [: ]- }: T$ H) e, c+ ]
行,这个怎么样
0 _* J( u0 d7 N. y- package com.xhg78999.mtrfac.render;" r% z7 F/ ?- R4 x4 M4 N* e
- * X% l6 K+ c) B5 P$ B
- import com.mojang.blaze3d.vertex.PoseStack;
8 Q3 f5 r/ H$ {& P - import com.mojang.blaze3d.vertex.VertexConsumer;
6 r2 i: `3 d' t: ^: L+ m - import net.minecraft.client.renderer.RenderType;
+ ^) f' ^, \1 Q) W - import net.minecraft.resources.ResourceLocation;
! u9 p* Q* Q _3 p+ a { - : W- Y2 m* W; J2 s( {1 c6 ^$ y+ P- d
- import java.util.*;/ I, M( a/ u B: \& x
: D" \4 W- n* D& r/ `+ Z& r- z- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
7 s% v( f) `: _' n
F. I% {; N2 O7 O6 D! S1 R- public class LineRender{
; i) |& n5 a8 R5 c% R2 E2 M - private final PoseStack pose;" L! c7 [& G1 N- j% j. [7 K
- private final MultiBufferSource source;
+ L3 n" [) L- p - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
4 g8 G, A' _0 H- C - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();" ^8 F& a4 A2 O3 i
- & a7 v2 t, s) y, Y, b* ~
- 4 {5 U5 Z9 I% i' z# J6 u- m
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){" d/ `, ~% E+ i- R- x
- if(x1 == x2 && y1 == y2 && z1 == z2){" E7 v! f3 O: {/ C0 m. {& ]
- return;
1 G9 u$ T' w" M# R0 ]; N& t) | - }
6 R3 l7 \0 @! F8 P; K - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
+ d0 X8 x; n' H% s9 Y, L5 B1 r - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
6 |6 E4 K' U2 E" Z+ _ - }
6 }- [% d& a0 P; E) m* x3 I. B" J7 K - pose.pushPose();$ _3 K4 i' l' O' I$ y& |( \
- final int newLight = convertLight(6);1 Q# j/ F; |: ?
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));! t. `; Y+ z, T0 h* s) g* k/ a
- final float lineHeightSmall = (y2 - y1);. J$ g& R! E, O
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);0 O4 C. e" P( [# }; t
- pose.popPose();0 I& S% X, ?; @0 S$ b ~$ B
- }
- p; z1 q8 b2 c: j8 q5 y - 4 O" ~/ I+ l: D* O- k3 \6 m
- private RenderType getLayers(String texture, int light) {
+ p) d4 b2 ]8 J$ f$ v9 S' B - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));' x' F3 P/ `2 y7 R# a t
- }
$ b2 a: P) F, L4 }/ b% f
; g( ]" {% E' n% l- private RenderType getLightTexture(ResourceLocation texture) {
, j. h7 P* I- Y; g" S; { - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
. y0 ^# n/ k u5 X! x) h - }
! G. M6 C/ G% [7 U - / i9 b) s3 M$ s. |& n1 S
- private RenderType getTexture(ResourceLocation texture) {/ w# i' D/ ?! C2 ~1 ~/ U; u
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
4 J8 \! z7 `1 s. O: @& }4 y - }) J* {1 r! v( U# y
- $ M3 m1 l2 `+ e8 c1 o- ~4 q
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
* w( k. t& ~2 C) b+ y - if (cache.containsKey(identifier)) {/ w; L# r9 ^% R5 p- \' R6 G* n
- return cache.get(identifier);5 a0 ]+ @* T0 ]/ U
- } else {
) R' a8 F/ [6 A$ e$ A - final RenderType renderLayer = supplier.get();
4 t( l3 A. v [7 r# v# S0 i' Q. b - cache.put(identifier, renderLayer);
/ g! F. Q: R& @$ Z2 a# q% H& r/ P - return renderLayer;
# m( r( c, ?- O9 p* @ - }. U( @/ d/ O9 C( S3 v( ]
- }0 T( k- m* D& h+ k+ X1 ^
- }
复制代码 |
|