|
|
% X& _( c% o7 t, [% U0 q* J; J) a0 w( ?行,这个怎么样
- M, U: W: c( c1 z) v( a$ c- n1 U$ u- package com.xhg78999.mtrfac.render;
& b& N l2 r6 U! k( O9 D - 7 X7 R8 b$ o! D' c& p/ X
- import com.mojang.blaze3d.vertex.PoseStack;
# B4 m5 g G. g* B' d& ` - import com.mojang.blaze3d.vertex.VertexConsumer;
7 F! T8 z! A1 p3 ~8 g- J/ d7 U - import net.minecraft.client.renderer.RenderType;
- b. G$ Y* K( ~ d1 ^ - import net.minecraft.resources.ResourceLocation;+ y' Q1 Q8 p" l+ ]: q' [) w
- * U2 L/ N' n5 U
- import java.util.*;
$ ~1 |% d! G! [' K4 F- N
7 S- }5 M7 e2 _" K; [- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
+ w( ]- @$ ^6 S
- B9 j0 j9 c9 Q# r" N) m- b1 X, X- public class LineRender{3 f7 b+ A3 W4 E5 i
- private final PoseStack pose;8 L7 F1 o! g/ [7 o
- private final MultiBufferSource source;
& u5 m1 X% r9 b" e/ v" W) F - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
; k, L7 ~3 a" H: v' l - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();/ N2 Y- t- p8 {0 }. O; ^+ t7 S
/ u) b4 E1 `/ K) _' Z$ T- # I5 l: `1 A4 N5 v
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
_. }( U1 @& O0 T2 H( I5 s1 k - if(x1 == x2 && y1 == y2 && z1 == z2){
9 x) L; S- v( O- n - return;
' t: q! b2 ]/ E - }
+ y9 f, K+ L v; l' H( f9 ^$ ~$ w- E' N - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){% G2 T( _0 `: F) ?! C
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
: I0 v& H( g! I( M - }( M+ f: ?1 \2 X( [' c8 h# \8 Z. e
- pose.pushPose();
6 f1 _/ g2 B* a; x3 M+ d - final int newLight = convertLight(6);
1 e, k1 f8 {, x2 U. c - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));# o9 t2 R% Y6 x) I
- final float lineHeightSmall = (y2 - y1);
$ {& G; f# M$ J6 ` - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight); ?& S) X, ]6 @0 F) h3 }& L4 v
- pose.popPose();
2 ]4 W5 \/ F9 K& j4 ]8 ^ - }0 k1 [+ B! J. t" M0 y0 Z. t
- 6 q i0 F2 R1 [+ N+ o
- private RenderType getLayers(String texture, int light) {
* f/ Q( @+ B( t% r! @+ E - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));4 k" F& B7 z1 i6 f8 Q
- }
8 h5 r3 [( h" l9 Y/ O% u+ ~
) Z& T* }) k& z( L* C6 H& ]- F- private RenderType getLightTexture(ResourceLocation texture) {
7 p/ ^2 F+ b; E - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
, k. ?, U& L) F - }; B" h' `8 p% v" v- O) ~
9 h7 `3 B. e2 |; ` E% [- private RenderType getTexture(ResourceLocation texture) {( \" l; y3 |) j( e
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
# v5 {! M8 M+ M# d$ Y; o - }5 R3 @2 C# _; C0 ?' g7 N
. t, c) D4 C7 ?$ [3 w4 ~1 i- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {4 Q; C8 s" o5 w# p. z v% v
- if (cache.containsKey(identifier)) {
5 i2 T, k0 j ?0 q7 h5 g. o9 ]- N - return cache.get(identifier);" }: e# P6 _. k" }; Q, y
- } else {
: S9 T( E; c! X' A9 i - final RenderType renderLayer = supplier.get();
4 \1 S! G M4 `& `) W1 t - cache.put(identifier, renderLayer);8 W6 i0 w( Y8 \6 d9 D c. I" s
- return renderLayer;
- \( R) ~3 k: N3 N" h - }( e- w Q+ \2 B! a/ m5 f
- }; X( z) ~2 I6 T& J
- }
复制代码 |
|