|
|
* I) ~( T6 t" D; C. p行,这个怎么样
9 A$ r8 h* X) q# S, S- package com.xhg78999.mtrfac.render;1 k8 E/ W! {! O" l( h
/ s: J a' H& N' p: {' ~' G+ q* ]- import com.mojang.blaze3d.vertex.PoseStack;6 {; r' M# z i# m: G: f2 b
- import com.mojang.blaze3d.vertex.VertexConsumer;
9 z4 B1 I, r& N+ P) z+ ]% Q' x - import net.minecraft.client.renderer.RenderType;
2 S, w/ m6 t/ y& r - import net.minecraft.resources.ResourceLocation;5 U) O$ Q) D' T
- 7 W/ U2 Q$ ^1 n$ k
- import java.util.*;3 T% k4 r4 L" X
' ^2 f6 O. k. R3 T+ F- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
( [; ^; X9 u/ r4 V/ h/ {, m - " ?3 l4 p1 C+ U* {. X
- public class LineRender{
" d& i, H/ T9 }' u! M - private final PoseStack pose;/ q# `: n# N5 {# E
- private final MultiBufferSource source;8 D( j% B% ~9 W; b5 ?
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
9 }8 W' q* }; v - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
: O' s; w' Z/ e( O/ H3 n - ( U j: C; M/ Q4 E! L, W
- 3 Y3 ^* W! _/ h0 x" I1 W0 V
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){- F* A+ V: Y" _% O
- if(x1 == x2 && y1 == y2 && z1 == z2){
! k5 j% v$ I8 k5 }5 A3 u/ K - return;0 a: e7 D+ M0 a; P f8 |4 r
- }" `4 w+ J2 Z6 f6 j3 t; X
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){6 ^5 x* p: |( x: [* p# Y
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");0 g4 Z, ]4 H( ~8 V6 l
- }/ r# h! X4 Z7 l; Y7 S! C
- pose.pushPose();! D3 k* b% J5 \5 h. s: p+ o
- final int newLight = convertLight(6);2 f, f' f( l; N6 {
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
: }9 H6 O: L3 N& h$ ]3 f& P - final float lineHeightSmall = (y2 - y1);) I( m: _5 a' O. x& e
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);9 r& d# H8 Y F9 n
- pose.popPose();9 Z; i2 ^- m. b3 r v8 B+ S
- }* p- Q1 ]9 u7 g' T1 l% a; q8 W7 w
- 7 P( Y9 S: ^1 m- A( p1 G
- private RenderType getLayers(String texture, int light) {3 }4 }6 u4 o+ t u* i3 W7 e
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));. A) S! t( V& f( y' ^. I
- }
4 M' G! N! Q* x4 c9 h. \
- X$ V8 ]* s* \: p$ a5 F- private RenderType getLightTexture(ResourceLocation texture) {
# ^5 K) @7 _& ?; e' U' k" j3 O' O - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
8 T2 T2 B$ x; O+ F/ c& s - }) J2 J9 E" E; W% U- t+ s
0 K: j4 r- o, L0 q1 D' o- private RenderType getTexture(ResourceLocation texture) {
9 P, k; B" H2 L: W }4 q/ I - return this.cache(texture, () -> entityCutout(texture), CACHE_B);* H) a; i( _6 [3 v
- }7 n( d) F3 i9 G u; G& ]1 T% ^
- , C/ A: x8 j R4 {' o/ v8 I
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {( |' a! G- K w8 B' f
- if (cache.containsKey(identifier)) {
; [2 x7 N) H( d0 } - return cache.get(identifier);
: O0 }2 B9 L+ U/ r- b - } else {4 [' H, i9 ?5 P
- final RenderType renderLayer = supplier.get();+ m" f! | H/ Y4 b) B
- cache.put(identifier, renderLayer); o4 v5 e+ j8 U7 ^! l7 k
- return renderLayer;
2 `/ c1 H/ ~' X4 @ - }' T1 m8 b* p' a
- }
4 Z2 O1 b; c9 I2 G D8 I+ S+ l - }
复制代码 |
|