|
|
4 l7 y6 j9 a2 C! a行,这个怎么样. S8 k/ s$ C# f- O* d- T
- package com.xhg78999.mtrfac.render;9 i6 Z, T+ i6 L3 H% s
& V- \, W# `& r8 ^7 |- import com.mojang.blaze3d.vertex.PoseStack; n7 B% Q5 l7 `" e6 X! C1 f
- import com.mojang.blaze3d.vertex.VertexConsumer;1 |. Q: b* x5 b: O6 H& z( f2 P
- import net.minecraft.client.renderer.RenderType;
5 W2 {9 A# f" t# M; h# _) r3 p - import net.minecraft.resources.ResourceLocation;
6 W4 N, l5 C a U% w8 b/ Y r
' F8 I3 x# E, P7 D/ z- import java.util.*;$ B5 h* Q( r* x$ |; |$ N# ]
- + X8 Q4 B4 N1 F# \) R$ \
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
% [, _/ z4 ?! z* [# ?* l - 5 @( R# \: n$ c1 C9 g, x& ~5 N+ q
- public class LineRender{7 X6 }/ [" z4 b2 ^4 D1 T5 ^
- private final PoseStack pose;& L& S& r% r" B( u$ M
- private final MultiBufferSource source;" g9 H2 [" |7 [% b* a9 f, z
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
N+ g8 w; n0 d& |+ \; F* Q - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();" [' P( q1 n3 N5 R- G
; }) x, H# M7 s- [
, t& h! c% _- R6 @5 W$ p/ x- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
8 o5 O. L. g4 S1 o) \8 T8 v - if(x1 == x2 && y1 == y2 && z1 == z2){! D% I) c; N( A* c
- return;
+ o% R! s' d8 L( }+ l1 s' Z - }
% L5 }" _( H! T3 D- C3 f% I - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){ e9 R1 A8 @" q; B4 q' E: z* h. p
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
9 G3 G$ {0 R( {0 G+ k, e1 i( p - }+ z% M9 v3 X0 z$ Q, Q/ J
- pose.pushPose();% Q) f. R# w/ b' v4 D9 f$ @3 o
- final int newLight = convertLight(6);
5 _( \0 U5 l4 y; u - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));8 h, @" J! n0 o/ l1 l* B# d; N
- final float lineHeightSmall = (y2 - y1);
4 U+ s3 ^" Y- m9 z$ w0 u - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);1 A3 k0 u! r5 ^" U; s
- pose.popPose();
2 p& E, l) y% B, p* a - }
- X8 s5 K+ g7 d% n( b - ( Z4 T) N0 Z8 N( u
- private RenderType getLayers(String texture, int light) {, ?. e, t8 {2 Z, Z/ _
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));# _- {- L. e/ f e2 T
- }: w t$ p5 I F/ A* [- p# B6 W
- ; \$ f& Z4 U0 a# E9 M Q2 `
- private RenderType getLightTexture(ResourceLocation texture) {
: B0 ?0 r! X! _7 }3 t; c# H1 y - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);. a. }. c4 }5 _* i( G8 b0 d
- }- b9 F2 f3 W0 _) Y' N
- . R0 P; J0 I# ^. k
- private RenderType getTexture(ResourceLocation texture) {; z- c- e* i! \! D' z: G
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);" D+ P" j' c- {8 Y" w7 X3 X% |
- }. N0 l& F# u6 }' M" P5 G+ `5 I
0 z9 W' H/ D& U% a0 L6 P/ q- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
/ u3 \. T& |, Y4 } - if (cache.containsKey(identifier)) {
4 F9 G9 k$ n' {/ r - return cache.get(identifier); X" M) ]; K1 G+ t* |0 d. S
- } else {
! ^. i: u1 Z: F9 } `- o - final RenderType renderLayer = supplier.get();
3 D! P# L" ]1 _9 {8 n0 P - cache.put(identifier, renderLayer);3 w* D+ W. \+ p$ b+ m" X$ Q( i
- return renderLayer;4 g m$ ~' S7 g% F, Z6 p
- }" D) p7 X0 I5 f: ` L+ m p2 w
- }
4 u O7 @% T; U. ~9 G; L - }
复制代码 |
|