|
|
8 V, Q6 x: [9 f' x- H* X# a# E行,这个怎么样+ O) F- `/ b: [, ^6 @4 L
- package com.xhg78999.mtrfac.render;/ t. S" a2 O" A4 _( h) g5 v9 {" |, x0 q
- 5 D8 o6 b2 S8 V1 s
- import com.mojang.blaze3d.vertex.PoseStack; ], P% p( I0 I% `8 r5 b2 g
- import com.mojang.blaze3d.vertex.VertexConsumer;
# ]2 u) m& [% F a - import net.minecraft.client.renderer.RenderType;! K! r* Z8 q/ B5 ^: P, G7 B
- import net.minecraft.resources.ResourceLocation;) z' V6 V/ d9 ?7 r4 o0 A
- ' Z1 y3 j9 V3 K D7 g0 M
- import java.util.*;
' ^$ M: ^+ g' z" p
( A* ] w% y- ^) x- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
4 T$ ^2 c7 ?% |, D' \3 k) A - 4 {3 n% T6 x: s+ ^" u
- public class LineRender{
$ L6 T8 x1 C' s( y: C% X - private final PoseStack pose;7 @" W& Y% `' }# m% m8 T- n6 i6 T( A+ B
- private final MultiBufferSource source;% Y- V7 g: s0 z8 Y
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
5 ^' w. b# B- b( T9 w: o - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();, E8 q w/ d' o7 m* z+ Y" l
- & p+ {8 _% R3 q W b
" J8 U4 ^, n3 O$ E/ F4 l3 B: K- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){) d- x2 e* d& H; R/ ~# Q1 ]# e4 s
- if(x1 == x2 && y1 == y2 && z1 == z2){+ G9 F. I7 \: Z
- return;( `" m- i" i% u# J3 G1 r1 w$ T* k2 } c
- }
0 v6 k7 E9 v2 P5 I, Q - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
1 o* b; O, g1 a ^ - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");: M5 C6 Z/ f0 f s7 t! r
- }
5 g1 f0 B8 W# Q - pose.pushPose();
+ U' n+ x8 G4 U - final int newLight = convertLight(6); M' I. h% r* n
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));( C; D P8 a/ F% r" w
- final float lineHeightSmall = (y2 - y1);1 v& F4 p; y W, o8 c' o
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
9 B; S# t1 C( P7 H - pose.popPose();
! P; }1 ~$ E. l2 M; s/ m: W - }
* j, V- h) S+ [( [ - ' a2 Y/ z6 Q+ ~- w
- private RenderType getLayers(String texture, int light) {: M/ \* t; x. N0 ]- r& E
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));; \, O3 Z4 r2 \8 ]$ y
- }* g7 h; }6 X* b1 m7 }7 c8 Q" \
4 v' l1 s0 H# b/ L- private RenderType getLightTexture(ResourceLocation texture) {
( f4 T9 a# ?9 Q. c - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
! j* C E- `/ H% K% \ - }/ a9 d3 q& h' |4 H
|4 U# C( h, T+ C- private RenderType getTexture(ResourceLocation texture) {
8 o& Z7 Z: u5 o3 D2 P0 [ - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
M; `: \' V7 P, A& `7 h+ k) p - }( w; ~" C4 Z8 v! ~' h4 m
7 C6 t4 B' c1 F3 B- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
) O* z5 d# _, g$ c& }2 V - if (cache.containsKey(identifier)) {
/ a8 b+ x: T2 T& Z - return cache.get(identifier);
% M1 |9 b3 w8 N- u8 j$ e n - } else {* p$ J- R& _! v$ P
- final RenderType renderLayer = supplier.get();; L. A) i6 o' n1 Z+ r; I% P, X
- cache.put(identifier, renderLayer);& K) J# _2 j- a* N/ R
- return renderLayer;
+ k% \3 S6 F- O - }
1 Z6 x1 M( N5 [9 i3 i) Q - }
( t$ A1 \/ X+ r6 H% R; b - }
复制代码 |
|