|
|
t9 E& G! v. g+ g- N行,这个怎么样
' ~6 d. H4 h8 A7 L6 V8 B" ?& s- package com.xhg78999.mtrfac.render;
# o3 E @2 ~% Y0 a
7 I( K- N9 I/ e% ~# i- import com.mojang.blaze3d.vertex.PoseStack;
( W* D5 q. L) H6 S( k - import com.mojang.blaze3d.vertex.VertexConsumer;% ^; G3 A# c9 {) p3 r: c! q* h7 k0 {
- import net.minecraft.client.renderer.RenderType;
$ X$ ]8 V. J6 M& s: H. [% W% U - import net.minecraft.resources.ResourceLocation;2 k. v h; ~3 O: ]# Z& j" o4 n
- L5 P: a% \ L) ]
- import java.util.*;$ n8 B, G8 W8 R7 R1 d
- # F( p) t5 s, j. l; {
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
) T- r2 t }$ m - . D- Q( S4 X: t1 {4 I
- public class LineRender{. Z% ^6 T/ z9 Y# K7 z6 F0 o
- private final PoseStack pose;
, L4 Y, w( g; l0 M: ~7 [ - private final MultiBufferSource source;
! E& y, T+ t& m+ G - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
' r y2 v+ D. g3 W+ d1 e - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
p! H: w9 l( N" T - - v4 H+ d8 V8 ]; E% D2 T7 V
9 j7 K$ {/ j, _9 R+ F7 F- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
7 z0 d/ f/ d9 T( t0 H - if(x1 == x2 && y1 == y2 && z1 == z2){
+ v5 }( i" G' J; C* m5 Z' F: [5 U e - return;' p6 ?9 \: v6 Z d. L" L
- }! Y1 v; }% }$ `: F) P' N) L% X1 i
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){$ V5 x/ J1 l2 w
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
' j0 b9 d1 p8 ~& a' ^9 K - }! u% C# H/ }* l5 ^! N( R0 B
- pose.pushPose();
+ Q, N, L& t1 g* Z. T$ C0 T - final int newLight = convertLight(6);
( t( i1 ?; S) T3 ]3 C& e/ x - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
. Q; P( j- e/ L' e - final float lineHeightSmall = (y2 - y1);0 F2 o2 K0 W6 W: A4 k O
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
4 y0 K. [7 e; k2 M- b- i - pose.popPose();! R* v+ t; {; K9 {2 b6 g9 z1 Z
- }# x3 C4 `4 w0 g* i7 ?% I4 C& g
- 4 h' M a+ Z7 V0 P7 W) C# ]
- private RenderType getLayers(String texture, int light) {8 u$ c9 ~( M, u9 A: v8 W( c
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));' a* r' s5 ?9 L8 S& Z0 y) U" x5 t
- }3 s) H+ k) ~7 E: ~" v1 F" @
9 }* V1 m/ K5 p; P0 w3 X4 M- private RenderType getLightTexture(ResourceLocation texture) {
" Z6 F! ]+ @9 E9 [$ A6 |7 \' p; E7 b - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
4 o9 X# g' W; p j - }& I) W4 J9 |" a7 v' ~
- * J0 A! e# ^4 \& E+ ?% p
- private RenderType getTexture(ResourceLocation texture) {
d8 t8 d/ a d' f( x5 f - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
" K5 {) T H- S5 Y9 W7 {+ T - }6 C# q$ @& N6 B' V( T5 b
- " m# J# z, A" T" ~- ]1 G
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {7 {# W. ^: x6 E6 u9 E
- if (cache.containsKey(identifier)) {
9 y- X! O4 t1 C; \9 W - return cache.get(identifier);3 c( ^% [4 q* Y3 N/ j0 C
- } else {4 H+ c4 p* ~0 V" s" K# _0 H2 F
- final RenderType renderLayer = supplier.get();" s! n& D! e! u; m' j: A
- cache.put(identifier, renderLayer);
) R* f( o( e6 X/ J9 D( ] - return renderLayer;7 C9 h/ K# L/ Z! u" e
- }, { z) [+ K8 W, E6 }
- }
+ w7 s! g4 c( A6 J0 W; {& H - }
复制代码 |
|