|
|
) a9 N" u1 f. S7 ^" S2 L" \: k, s: z行,这个怎么样+ X7 h3 H2 e& g6 m7 _
- package com.xhg78999.mtrfac.render;
! @. s# z! W7 t6 W6 b
7 }* }7 M2 F+ z0 `, b) R- import com.mojang.blaze3d.vertex.PoseStack;; r2 ?) }1 J. @6 z4 w2 o# H
- import com.mojang.blaze3d.vertex.VertexConsumer;! v" \) R# T/ j; I5 k4 z3 e1 F* U$ _6 Z
- import net.minecraft.client.renderer.RenderType;
5 U( g1 b% B/ T$ I' D7 U2 T! u, ?: J - import net.minecraft.resources.ResourceLocation;& t$ _5 K3 e4 K, |3 L! v
- ) o q" O- k n& R6 @# K
- import java.util.*;
/ ?; f) Q z8 o. \" {2 a - 1 j4 l9 A+ n( K1 O7 b
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
7 [/ u6 U+ G( w1 X7 Q
* ^( ?) I4 r4 U! V! z4 h) K( m- public class LineRender{
' {0 e% R3 t- O/ w& F; k0 | - private final PoseStack pose;) t0 O+ f/ O3 f' r4 ]+ k
- private final MultiBufferSource source;
. r5 J& L. b5 r) x - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
3 M! E% ]& L! M( Z& { - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
0 v/ x. _# J. {* Z0 [7 A4 a0 V H: k - $ {$ ?! A- R; Z L
e9 ^1 k" [4 G! j( Y4 b- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
) [& U" O( z) d - if(x1 == x2 && y1 == y2 && z1 == z2){+ f3 j5 e' r* C: C' s, z0 r0 Y
- return;) [; m: ^' a0 R- M& K
- }
: n1 ?# b, q* I2 X - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
0 @# l5 }1 K' Q; p3 G& r) t - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");4 `- n. }3 H4 l* P3 l
- }
( S8 q) K/ M: @6 H3 T) w8 D - pose.pushPose();
$ q2 n) d! ]# [ - final int newLight = convertLight(6);
8 w! O8 j6 ^0 d - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));% c$ e1 T/ ?& d5 }! i" E$ l
- final float lineHeightSmall = (y2 - y1);
" e5 E4 G/ y' [* o6 M. \ - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);- N: u" z/ L- y+ ]" v7 l, N! X
- pose.popPose();+ {5 e2 J% K) c* o( O
- }$ V7 ? v) ? P7 k' T ?! D
- % i C4 C2 I, p+ H4 b
- private RenderType getLayers(String texture, int light) {
6 X5 S" l3 @: ]" p" Z) W" ? - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));* B3 } k7 x9 e. n' A s
- }
9 ^ D2 [$ F8 y/ R; w9 E
+ J l7 M3 t f0 H8 g2 {& n- private RenderType getLightTexture(ResourceLocation texture) {1 e- p. ^ v' c: k% K% c
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
! d8 _2 Z8 V7 F/ {" m; H7 O - }
; c; n3 y4 {( a6 L7 W! i- g5 Q
: Q) G Y% K4 [8 J1 A/ K- private RenderType getTexture(ResourceLocation texture) {
r! P$ n7 p/ O* F - return this.cache(texture, () -> entityCutout(texture), CACHE_B);5 B$ h3 `& W2 ~4 O
- }: B, w2 T+ K% i2 n, x0 T
- 4 p N+ w: l; X! m3 f
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {+ o6 B; r8 H, o! p0 T" y
- if (cache.containsKey(identifier)) {) H$ P9 E$ C3 N& b
- return cache.get(identifier);
2 t3 r. |1 E6 M+ I% }( d - } else {; k) ~! L2 L9 ^2 h0 k T
- final RenderType renderLayer = supplier.get();
, y) K1 h# V: c- ~ W - cache.put(identifier, renderLayer);
) Z' q1 _% Y$ J% Z( f; x q - return renderLayer;+ ]/ l7 h6 F) R: ] t( U
- }1 b+ I; c* ^$ X `
- }" Q' N4 T. {) G! ^- F) L; n
- }
复制代码 |
|