|
|
: s5 K: R$ y1 \, v$ Z
行,这个怎么样/ K- x d Z% e3 G; }) e: [
- package com.xhg78999.mtrfac.render;8 q# h' ^- c3 a' m' V) R
- / _8 e/ K# d7 T! Q
- import com.mojang.blaze3d.vertex.PoseStack;
0 ~- A7 z: ?; M7 r! E& n) C4 u% ] - import com.mojang.blaze3d.vertex.VertexConsumer;
$ \# U( }# N8 T4 \" ^ - import net.minecraft.client.renderer.RenderType;* U; f. F8 x. x/ \6 l
- import net.minecraft.resources.ResourceLocation;
8 {: u; o9 b) `4 @4 H5 c
, @9 z0 L, @7 ~! d- import java.util.*;9 I% o" |5 Z8 L# M3 ]; b( j
- % `- v: V' t" Z! S! Y! S
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(( A: M; Y) P9 q% ?1 e% u
" _3 u. y7 s4 N& ~- public class LineRender{+ q" }# C. K' L' x( x; u7 k
- private final PoseStack pose;
. o9 r( `/ u% G4 M6 V - private final MultiBufferSource source;5 ^( c' s7 j! j; {8 x
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();: G2 T8 J: g2 p- H) ^$ D( u
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();1 U; T$ [4 S0 r# e
- . G: U2 S1 ?4 Z" L
$ w3 B$ T+ }% _- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
! J6 {; l; j- `# l$ p: d - if(x1 == x2 && y1 == y2 && z1 == z2){
" _% n i8 s5 M9 C& K$ ?1 B - return;
; k/ _" n- G, w8 j5 F, [7 o - }
3 W7 p0 z7 t* n% ?1 a - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){" I* ?( d6 K7 e% z7 X
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");; ?/ m2 e) T9 o8 E3 _) ^& C* q# R) P
- }
1 o. U* r X" Y& E9 t# h x2 ]7 P - pose.pushPose();
/ s4 Y9 s$ @+ b2 y - final int newLight = convertLight(6);& M0 k% x2 l! g2 c7 y
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
1 S6 ?1 P* n% z9 D - final float lineHeightSmall = (y2 - y1);
}; U# f0 I: y9 ]' q, G R0 y - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
! ]/ X" R8 k+ e+ u6 g$ m, i - pose.popPose();" F3 ?. k8 e( u# s7 f$ l( G
- }4 l7 }! ^4 R) I, N$ g
0 l. H8 @# \4 y- private RenderType getLayers(String texture, int light) {
# Y2 }5 t7 |3 y1 y& A% T - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));; E2 m. t* _; T3 g
- }2 H* F0 I7 w1 U
- 4 m/ B. T5 ]+ x) ~$ T
- private RenderType getLightTexture(ResourceLocation texture) {/ \% \2 }0 [( H. O, k8 G
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
. R: h$ f; U$ g - }& K: u) N j& A$ A+ ^
1 ]4 h8 a) x. H0 h. z- private RenderType getTexture(ResourceLocation texture) {
% p! N0 B+ G; X, P3 N - return this.cache(texture, () -> entityCutout(texture), CACHE_B);4 }' L1 o0 p8 {3 W+ e
- }
9 [" ?9 |0 t" A/ {2 P - ]! d/ y- B8 X' k! X# T
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {% M( }& I5 Z; r b4 _
- if (cache.containsKey(identifier)) {% b1 G h# P/ e/ x
- return cache.get(identifier);
j2 V5 ^ F. G2 O) l8 {+ G - } else {, p! H, {/ ~, L5 h
- final RenderType renderLayer = supplier.get();
0 ~% h7 j& D" h+ R - cache.put(identifier, renderLayer);* N* s& G, Q b1 d' j) ]# \1 i: z
- return renderLayer;; _4 j' z, U9 i, g* v! B
- }
: U) W: v' p) p - }9 T' U' p. x* _
- }
复制代码 |
|