|
|
% z0 F8 N0 ~; _' m2 X) D# K. P行,这个怎么样' P' A9 J! r) X# T5 q3 c# F% ?
- package com.xhg78999.mtrfac.render;1 F; n& u! v9 B" G( v, h+ v
- 1 X3 ~2 ]- c6 ~1 L3 Q
- import com.mojang.blaze3d.vertex.PoseStack;
7 j& q% J. m: N; N7 _" k0 q - import com.mojang.blaze3d.vertex.VertexConsumer;
$ O& g( t9 W) x9 v1 Y5 x2 z6 W% i. X - import net.minecraft.client.renderer.RenderType;
& f2 C! b" R6 H6 w/ x* j - import net.minecraft.resources.ResourceLocation;; r" r/ o0 P8 m( ^
- 7 c- X( L& V* `8 y+ B
- import java.util.*;2 r& t# h; L6 l- f2 A7 q
* x. W( r! L% @7 I- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
, [) Y) O) A4 B7 ~ - $ a2 j) W5 v3 ?: V" Y
- public class LineRender{" O7 E! v; e! q" A! d& T4 O
- private final PoseStack pose;1 B3 b( `; a# ?7 |) ]- W
- private final MultiBufferSource source;5 z& m! v7 I7 ]! |9 p _4 W
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
7 { H8 d. M9 P5 i% `3 I - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>(); t1 D" V9 `: c
- : _+ E) O4 @4 q$ {8 y* c
; `, `" y) }) |- L- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){; W/ R1 y: `6 ?5 d# i6 E& x
- if(x1 == x2 && y1 == y2 && z1 == z2){
* x) ^- w2 Q: `- r* M - return;
, u) _' P5 P. @0 }. a) B; g - }# J4 g) {, a' }$ k; `5 Y1 {5 t
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){8 K! [$ W( N5 y1 ^' Q
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");! g5 b8 r& t \2 B
- }
9 L) u8 n' l% z/ M - pose.pushPose();$ { D; _* b0 S
- final int newLight = convertLight(6);% }% k$ J- d6 D* i4 l
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));* @7 A! S4 {5 y; K! o/ K
- final float lineHeightSmall = (y2 - y1);
+ }, h' P, k$ t# A( a/ L4 n: W - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);1 v% E1 Z, Z, f' v0 u- z
- pose.popPose();
j/ P* v! B/ `3 i7 P( ^1 t) | - }5 B2 q2 q' ~( v( L
- , V ~6 |: { }1 a4 E$ S" R9 m. p! j
- private RenderType getLayers(String texture, int light) {5 I9 t; E* P3 t3 W: P8 Y2 F0 M* G I
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
. @$ C0 d% i( A0 T2 G% k* i - }
) F0 v+ I4 e' s* H( S F; `
+ w$ s; j1 I6 F. u1 q7 U4 L& L- private RenderType getLightTexture(ResourceLocation texture) {% [: ? ?0 ?4 i8 c8 Z5 P$ K2 J
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);6 M& X/ I# A" Z% c# b* L
- }
% [. u8 k& Z" g4 o
4 {2 `+ _6 J6 O: K4 f. R- d- private RenderType getTexture(ResourceLocation texture) {% c. e1 {* F3 y8 l: }8 s
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);/ \: b& ^0 P1 d
- }* Z2 u$ s: w; x( n
- 0 L r, v# d, H, ?
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {" K3 q1 L% Y: @% S5 |6 Q
- if (cache.containsKey(identifier)) {/ T- r3 S1 f4 f% V0 q. a
- return cache.get(identifier);
4 A1 Z4 {$ t, `3 ]6 W - } else {$ b% L5 s' N. @( ]
- final RenderType renderLayer = supplier.get();
' J# E7 i& @ D- j - cache.put(identifier, renderLayer);2 M. l9 r$ Y2 i! X
- return renderLayer;1 W7 o: k: w' N
- }; n; x: d; l% O: Y }
- }3 Q( A" S9 h! I; j/ n! H0 j
- }
复制代码 |
|