|
|
, ~- e& |& ?6 t! l" X; l) S- S
行,这个怎么样
& X. G/ W6 e$ Z- package com.xhg78999.mtrfac.render;8 Y1 G* W8 p+ J% A' x3 Y
E7 U) K# Q6 z) [1 Y/ H G- import com.mojang.blaze3d.vertex.PoseStack;
) O: \( K3 `$ p2 l9 a5 [ p - import com.mojang.blaze3d.vertex.VertexConsumer;
% V* N- {& c9 `& ~1 r* i' v - import net.minecraft.client.renderer.RenderType;- z; @1 J9 f+ b3 c
- import net.minecraft.resources.ResourceLocation;- Y3 e& Y7 S( L: l6 t0 H8 O- n3 J' Z
p1 g' V2 H# C2 V" y; K, Z- import java.util.*;5 m3 S, X8 R2 l) Y Y' Y
2 X" f" b' \' U6 v/ X" M& q- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(9 [$ l- K/ B l6 P* W8 C
- 8 a. H7 R P5 ^% e4 ?- J8 b* m
- public class LineRender{0 m6 |* ~* \# c8 U2 p/ ]
- private final PoseStack pose;+ z* ?0 _) N% K0 a
- private final MultiBufferSource source;8 i6 y7 S& m1 x/ N
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();8 q' J; F+ o. X
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
. c& d- N* F" Y. a: c( I/ ^; R
7 H+ k$ B. l) T' A4 h; \# p. x
! R ?1 Y* Q6 K- _3 I- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){* P1 F7 i- C- V
- if(x1 == x2 && y1 == y2 && z1 == z2){ j# b6 m0 R8 H, R7 j7 W0 Y& g
- return;
- B3 {4 z- F' }+ u ^! q7 P! B3 W - }
' `% ? R- U0 Y3 n" l - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
0 J( [. k+ T. i* i - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
8 W, a: t( N. Z/ W5 a( i2 [/ H& o - }
2 O+ a* T$ O- y& ~ - pose.pushPose();. b n' t w, M7 x! o0 P
- final int newLight = convertLight(6);
; n' Z0 e7 r6 r6 { - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));) z [1 P3 `0 @' s
- final float lineHeightSmall = (y2 - y1);
& o+ C$ ^% E) C* s& ^1 ^ - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
. G3 X _! n: C - pose.popPose();
^) L0 w, I) {2 u- u" u! s - }1 p1 _4 B& B$ W9 q- @
- 7 r/ d8 X" |/ k( Q9 o
- private RenderType getLayers(String texture, int light) {5 X. D2 x& m/ A8 g S9 I1 J
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
0 S( V/ l# D K. s - }9 u! o* g! ~3 |, N4 r" B) T; o5 w
8 U, I4 J9 _: \, X, J- private RenderType getLightTexture(ResourceLocation texture) {' h9 r* X4 r- v5 V% d9 F
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
2 G t: ]& d' p7 f2 D - }& J( h) E/ @. m* V+ c) P: m& h" Z& d
- M7 W, ~! X( V) T
- private RenderType getTexture(ResourceLocation texture) {
. L7 d% F2 }) W5 ]9 ]1 ^9 {" g' X - return this.cache(texture, () -> entityCutout(texture), CACHE_B);" V4 @' n1 I G8 o: L' @
- }4 Y1 X' {7 x' s, w' s
; t8 Q4 M+ w9 g- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
4 P" `7 x8 H" i1 V; ` |. X2 i5 ?& L - if (cache.containsKey(identifier)) {
' n2 ]" Z0 t# ]& l( J" H - return cache.get(identifier);
+ K6 u5 _9 H3 `! I1 w - } else {
! j* d) v0 [7 I% r, Q* B% }. Y - final RenderType renderLayer = supplier.get();
4 ?" ?+ E. K% {( w! ~- ~$ e$ Y5 [! r - cache.put(identifier, renderLayer);
) H8 @! _$ |0 B8 ?# ` a - return renderLayer;
3 z: H2 [( E Z: A* S: i9 m; @" Q4 s - }
7 j$ I7 ]4 R9 i8 Q1 R- l - }
6 u% t( d% B: x# _# j - }
复制代码 |
|