|
|
# }3 I+ I: b5 [4 m! O行,这个怎么样. ~$ ^( Y: q" U8 |( y0 w
- package com.xhg78999.mtrfac.render;
7 z/ C2 A' P2 M, D! B& y1 w+ x) x - # q9 F' W4 U! I2 p5 A$ ?
- import com.mojang.blaze3d.vertex.PoseStack;: B" Q! u$ ]) ` G+ F
- import com.mojang.blaze3d.vertex.VertexConsumer;4 ?6 g1 O3 z- d1 K
- import net.minecraft.client.renderer.RenderType;# C' u6 c& ?% Y
- import net.minecraft.resources.ResourceLocation;* G# Y, u* @/ l) i" V" @ P8 }
- ( ^) X; d. U | u! P3 e
- import java.util.*;* t" h( m$ E" z& V1 P
- K" F; o4 j' H* M
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
# U8 `2 Z' {! w9 N+ c - " ?5 t5 }. }' q/ K( u1 ]8 L( Q3 }
- public class LineRender{
" _0 V. ~* t' {0 T - private final PoseStack pose;! b) W, |4 t" w8 Z9 f9 Y3 O
- private final MultiBufferSource source;( f' L' {' h2 d7 E7 T
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();1 q) Z! x9 f1 E; e
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();0 M, i: G; f' [* Z0 \, J
- % n+ b+ S$ U. X, \; X4 b+ V
$ Z& e- z) q! S2 e- C- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
7 ]0 f( J/ }& L - if(x1 == x2 && y1 == y2 && z1 == z2){# n; L: z! K; i' h0 O D" |* l: i
- return;
& q# _0 K8 i7 T% r% r) n+ Y4 S - }
3 q2 b6 v' w' g - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){3 ^ D) C8 ~/ \/ ^- U+ \
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
+ B/ u( f. X7 h) j6 ^ - }
3 s; L. l G: j0 j0 Z - pose.pushPose();0 O" Z7 ]6 ]2 Y# t- }
- final int newLight = convertLight(6);* f8 l. N/ k* B7 o
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));; S' k, v' }" H. M8 y1 A. x2 p
- final float lineHeightSmall = (y2 - y1);
# t, u5 x5 k- I/ g - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);9 u1 A. b8 y7 L6 d* x
- pose.popPose();% b: d9 v( f9 w9 z6 m
- }
( u3 n, X) e& w$ | k2 t
" z2 b8 N' w* h$ N N: G- private RenderType getLayers(String texture, int light) {
8 C& x% A- l2 {* k - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
, I, y# x7 B4 | - }6 ~ r. P% {2 H) s! F
- / _* u8 }3 Q& ?) h1 [
- private RenderType getLightTexture(ResourceLocation texture) {
% K( e: d/ q! F$ W; u - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
* H2 k5 M; V. m) g/ a - }
8 ^" w+ y4 K$ n* t
; r& X4 Q4 e- z+ X- private RenderType getTexture(ResourceLocation texture) {
; \2 U- I3 v/ Z+ |7 S8 V - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
* n9 H; A+ D; C% S - }
* h q( u: y$ v; E7 m& p- U - 6 O* S, C5 P$ E& z7 r8 g' i* Q
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {2 A+ Z0 y' O2 g5 c4 V+ Q2 R' E
- if (cache.containsKey(identifier)) {7 i9 ]0 @) B- O8 Z9 J. h* @" D1 y
- return cache.get(identifier);: o6 I L# O' w4 r0 C; `( A1 j
- } else {* s3 L& m O& A6 B+ k6 Y( ?& b
- final RenderType renderLayer = supplier.get();$ ]3 }+ B8 p" i ~ l
- cache.put(identifier, renderLayer);$ L% U" G5 w/ W( j
- return renderLayer;
8 \4 ~+ ?0 W0 y" F - }5 @$ X. Q: {/ k f# k5 y* X1 Z
- }9 w" c; U3 a3 Z; n; p8 ?: x0 ~
- }
复制代码 |
|