|
|
0 ^/ ^2 D5 ]' u8 h6 [: \6 K行,这个怎么样
2 W$ p# Q4 s( x( X$ h3 C- package com.xhg78999.mtrfac.render;: o* h5 b, x, ~6 B+ H) {& Y& L
4 h6 }; G( E9 W8 z7 J7 t# K. t- import com.mojang.blaze3d.vertex.PoseStack;
+ G+ I0 q4 o" q$ I - import com.mojang.blaze3d.vertex.VertexConsumer;
& ~0 x# o7 h8 c V - import net.minecraft.client.renderer.RenderType;( W1 s) V# l" G, P( W6 K+ K8 k
- import net.minecraft.resources.ResourceLocation;# a, y: V r; ^$ l" D
5 C5 x2 }8 A% N( |1 z7 g7 c- import java.util.*;
* K! Q+ Y! \6 d! B, e
) Z) H2 M2 B% s" [# o6 q- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
. U, O% H* A8 h6 {$ F1 }/ ]$ E - : R4 H7 y1 J: {4 h( Y% E
- public class LineRender{% c/ D f& K4 M/ K# B
- private final PoseStack pose;; R7 |3 r0 |! {# o
- private final MultiBufferSource source;
5 k5 ^* z6 `8 t* U - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
0 k4 `. ? ~) H% M1 Y" T' R8 F - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();7 e- J7 s2 l: f" O2 w! i
& c: I. i" ^+ u' @- + j K; K, e8 X+ S) o
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
0 J7 ^4 |0 ]& j - if(x1 == x2 && y1 == y2 && z1 == z2){
( T; {8 ~; n8 R - return;
1 _/ W1 F9 \ @2 g - }
! {/ j& S6 d" ]7 s* v& k1 n4 l/ L% ~ - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){8 L' F+ p% @" d8 s
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");! U" e7 m+ P# j) I
- }
/ S0 d% c* n( l u# Q- F - pose.pushPose();: C A5 ~" H- c1 V+ [
- final int newLight = convertLight(6);
/ G: `7 L- w/ z/ L - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
1 t* S! Y2 Q& `; B u - final float lineHeightSmall = (y2 - y1);
2 E8 @/ ]7 n g' u, k* L - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
5 c- n+ ]- U/ t& i: e6 `2 r% {& A - pose.popPose();5 r5 ]' p8 y8 |2 [! v4 o6 \
- }8 d S9 O: e& l9 u
( O6 r2 `& F0 v$ f4 p) Q- private RenderType getLayers(String texture, int light) {5 y+ r+ Y, g: g( O% b
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
) P1 y/ b1 Z ] o% `: H - }0 V! E) K+ k, @8 i0 r
- 4 n% |2 I- O6 T, T6 o; a# t
- private RenderType getLightTexture(ResourceLocation texture) {' G8 e9 B( b3 C7 M8 F/ ?( w) b/ ?
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
2 E' ]5 u% K/ C+ o - }( J# E6 x4 F9 X6 u
- - z3 p$ S1 i4 n& L$ w# H8 z& N" ^
- private RenderType getTexture(ResourceLocation texture) {9 M3 h3 o# M7 z8 D; e* i
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);9 `1 \3 F8 H. N8 G0 l0 c
- }
8 L. q& @9 Q' C- k( f! E9 D7 t - ! e2 L) y* q/ L
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {! V4 [5 k: M& J3 M8 Q, J
- if (cache.containsKey(identifier)) {
2 z" [* }! }% j7 g. L& Z! o - return cache.get(identifier);* h6 ~* t" i8 Q" Z( |3 f
- } else {0 B8 j3 z% ]9 l
- final RenderType renderLayer = supplier.get();! |. K5 ]; V% n% U+ G* X" z
- cache.put(identifier, renderLayer);
2 ?4 z5 E, Y) [% r9 a - return renderLayer;
: A W- j7 X% n - }( \/ [$ o4 R. E: ]$ F& O
- }
) S, A/ Y. T; T! U7 Z. Z/ E: w - }
复制代码 |
|