|
|
4 v. m& R- ^) E3 p
行,这个怎么样 ]" l/ B$ w9 r* x+ J' ^5 l& Q7 `
- package com.xhg78999.mtrfac.render;+ N3 k* D0 G1 ^" j
& G; Y4 |1 k# n. r# i- import com.mojang.blaze3d.vertex.PoseStack;9 J( i1 e: j0 W; ]8 j0 F1 A; O
- import com.mojang.blaze3d.vertex.VertexConsumer;! x: m, y, U1 ]% T b8 z
- import net.minecraft.client.renderer.RenderType;
2 x4 a8 y& Q' }9 I' T' y! c - import net.minecraft.resources.ResourceLocation;
8 I* Y6 B' N7 v" s, d2 G - ' c* h8 ~8 x+ f
- import java.util.*;
3 W7 w3 q* `/ Z4 g$ q8 u8 L
+ h+ k" N D7 t- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
' V, O, I4 {- t0 D% k5 @( g9 z - 6 J# i2 W' u$ e, f4 ]
- public class LineRender{
! G* {# u3 t( ~: h7 a8 J* |! N, s - private final PoseStack pose;
. n" }" @3 ?6 c, Q7 d' n - private final MultiBufferSource source;: C4 Q; W% R; [- w: Z4 o0 h! v
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();9 r# X3 X# y. z) [/ [
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();: }: E4 q! P% Q1 J3 R
5 ?8 l& x b/ c Z
2 w4 }. C: r" v) X# U- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){7 L0 G) M1 P) L/ O& g& {
- if(x1 == x2 && y1 == y2 && z1 == z2){* W; ?4 T+ N0 q3 T% K. j9 s2 U
- return;$ r. C& f% a7 _1 p5 |( T3 W
- }
9 U) L3 {4 ^6 j* G% {3 F7 m - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){: Q$ P, f8 D9 P3 e& h
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
( L: j8 \0 O' E. H - }
- e4 f9 B; x) x4 Y, ~2 r7 Z - pose.pushPose();2 e5 Q$ k" d s, T/ B$ i) n+ m" f6 Y( w
- final int newLight = convertLight(6);& Z. z& J2 B6 o/ Y5 d7 O/ m
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
: Y! R( Q. I. _* I6 a( P - final float lineHeightSmall = (y2 - y1);
- P# i0 N6 Y5 O3 |+ M# i$ ` - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
: Q( r1 X5 v; r3 I6 K - pose.popPose();1 d+ I! h9 f) m# _ `! Z
- }
( x s E/ _; ?' |( i - 0 }5 |. C. V. k3 |1 O* x; B' G
- private RenderType getLayers(String texture, int light) {
0 G5 M( g+ b, B: [+ W: y5 O - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));9 S) v# z" @; X
- }
" r |. M/ v( x; B - - d, }% d% G) x: ^4 }4 g4 U6 V$ m
- private RenderType getLightTexture(ResourceLocation texture) {
. n4 S I$ S8 R$ ?" y/ K - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
2 z; S" S+ [8 h# r: v3 A( E - }" ~* k8 B# H3 K( B, |2 @8 A% r$ h7 Z
- 8 R- P5 |! D9 q2 v. C
- private RenderType getTexture(ResourceLocation texture) {
, c/ i2 a h" P8 j7 O - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
* O9 w' I2 j0 J1 V1 c6 J7 m1 u2 m9 f; q - }
' ~2 k0 |, d9 L/ e: } - , S" v3 @$ A1 P, F
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {' B4 [' Z8 L! D, `
- if (cache.containsKey(identifier)) {9 r+ M5 V/ c, }6 \* y/ z& S
- return cache.get(identifier);+ ]+ Z; I# m" i8 i
- } else {- B; R. F/ o: m `$ l) T0 g
- final RenderType renderLayer = supplier.get();' R/ I* l( d' D" h6 F
- cache.put(identifier, renderLayer); A9 c$ b" B; M/ \
- return renderLayer;
( O1 S; }8 g; C2 g; L3 {$ L' A: M - }
: |) M! G! N1 P' J - }
+ h. V9 z4 }+ m& q, S5 `0 K - }
复制代码 |
|