|
|
/ o0 E% R) l0 Q行,这个怎么样
% j- K1 e" i$ b: i1 H- package com.xhg78999.mtrfac.render;& z3 N" t5 _1 W& k- S
; z# J7 B. N- Y4 k/ z0 P$ C- import com.mojang.blaze3d.vertex.PoseStack;
5 F) b1 m5 P# c - import com.mojang.blaze3d.vertex.VertexConsumer;
3 L$ i/ \+ t0 A+ Z4 h1 J - import net.minecraft.client.renderer.RenderType;: E/ n5 t. Q. j8 ` g
- import net.minecraft.resources.ResourceLocation;
$ z0 w9 x6 p0 K% z6 F+ l7 C7 R
! A9 |- y3 |1 o# q3 Q, A8 h y' ?- import java.util.*;
e; H: M- K* C: o
# B7 d% C5 X' B( W- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(, m T; e* ] e: n' G6 ~0 A# R$ i4 o
- - x2 [; V0 B R- a# \
- public class LineRender{
' s7 b# y# r. X5 W- n) X5 | - private final PoseStack pose;5 I1 Z6 n1 g5 F _. ^ p
- private final MultiBufferSource source;
- F" b. v9 l+ l' ?0 _# y) |/ b - private static final Map<String, RenderType> CACHE_A = new HashMap<>();1 N4 E' H1 y6 v4 C" z8 @3 z
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();9 r) k. e( m$ j* y' ]# v, p4 c
0 h8 o4 U% q! M4 G+ w2 i/ l. v F
+ l9 ?( T% i0 \ C4 a- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){/ f5 S3 n8 V- }& s% n- { N
- if(x1 == x2 && y1 == y2 && z1 == z2){
% x' @& Q2 @/ _ - return;" M* b! X8 E$ k6 M5 x1 F) s, d' G* \
- }: P( w; B# z9 t- V6 p0 U
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
3 ~" S4 H* [) a( g( R - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
3 V6 o" R- P$ C: {) q - }' h: Q# L5 E$ i4 R1 H4 h4 _
- pose.pushPose();7 I/ g6 O5 |# ~$ a
- final int newLight = convertLight(6);
2 R- U( w% L& m }# I - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
! K1 T- U1 f" h3 \9 n. K - final float lineHeightSmall = (y2 - y1);
! X. k9 }* A8 p: k: X8 |8 F - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
1 T: t' _7 R1 f. I5 n% p - pose.popPose();
: Q( U9 e' P9 X, b - }
: l, C( v* i9 V$ l0 Q/ W - 0 c0 x9 C/ {+ v( {0 @6 V) z* n
- private RenderType getLayers(String texture, int light) {
/ N: N# C* C8 H) w" S1 }& _ - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
8 U5 D, V& O* Q& i- y0 M - }2 t/ C% R4 D1 d. j6 u
1 c) z. `" H* R% y$ ]- private RenderType getLightTexture(ResourceLocation texture) {( x- ?2 U5 Q5 }" G' j$ }
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
( P9 Y4 ~3 p: C9 U) F2 u0 z - }
8 \& e0 d4 t b% l. S. D - 8 E4 O# ^. s3 R$ v8 K5 W9 H& I
- private RenderType getTexture(ResourceLocation texture) {- F5 s2 X; O$ l4 {: B* L
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);" e$ o- b! I9 O" P+ p+ P/ F
- }- m; p. _2 P; A4 v& p( a3 \
- , x! h/ J: y3 q& }( a( p
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {8 U6 l* e5 l# e M- H
- if (cache.containsKey(identifier)) {& k8 c+ {) \" S3 Y
- return cache.get(identifier);: Z/ b1 ~: k! Y9 P/ }
- } else {; z! |/ a# B+ [1 h O/ c
- final RenderType renderLayer = supplier.get();
$ z7 G6 H1 l1 ?5 m( p2 U - cache.put(identifier, renderLayer);; @8 c0 r5 J% W: G
- return renderLayer;9 I6 W( f$ O/ D9 c) F) e1 B, l
- }0 Q. [3 C4 p7 r! v
- }
' }1 h: O( ?. t& l& i0 Q5 V W B - }
复制代码 |
|