|
|
9 `! r0 x" l) [, w
行,这个怎么样
) Z, V2 u# T# G* [& z2 T7 o- X- package com.xhg78999.mtrfac.render;) V, e: [- o4 Z2 A
4 E: M( \; R# H8 b$ m- import com.mojang.blaze3d.vertex.PoseStack;
* P: J* l& _7 h+ z; T - import com.mojang.blaze3d.vertex.VertexConsumer;
( _. D3 e; s) o1 p2 E5 u - import net.minecraft.client.renderer.RenderType;
& H6 u* i% ?( A- S$ a - import net.minecraft.resources.ResourceLocation;
/ N1 [# V% u; F* U+ r `+ h
6 D% F* y5 l L2 I* y# s- import java.util.*;
. `" p+ m, _+ r5 {2 S4 f
5 X* J; e" h* v% h2 Y4 d- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(6 q; K. O2 n, D& I
7 O1 z% v- G' u+ @& K! c# H- public class LineRender{" U f- T+ y3 }. p5 I
- private final PoseStack pose;
! x: g+ C; W- W- [( e0 @; N - private final MultiBufferSource source;: Y: n0 H5 g- `/ o# B
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();6 D$ y8 L% v% w: n
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();0 F$ W4 B7 h9 p* R
- 6 e4 q% `' q: @% J4 ~$ ~
- 6 ?% `! ~- |/ t; _
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){! c1 H; |: o) R0 d
- if(x1 == x2 && y1 == y2 && z1 == z2){
. L p- h0 L/ I+ P: Z$ N7 ~4 P - return;
4 M. U$ b, | R- d - }
. ]" |- w9 E" \- i' E4 Q, q - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
! ~2 c+ m- A, z' {! h- O0 _ - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");( y; R# C; b& B4 o9 }
- }. Y$ P1 C+ T7 `, A4 F
- pose.pushPose();. q1 j( Q; L1 j7 o& G3 v6 B; w# y
- final int newLight = convertLight(6);
6 a$ F) o: Y3 L1 D4 l5 u! {- C - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
$ P6 ^5 t7 f& Z$ w0 x3 Q - final float lineHeightSmall = (y2 - y1);- b& W/ P0 b+ }* L: q9 s
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);6 G* e: O. l* J: u \
- pose.popPose();
8 J7 o! r; M- L( K - }
% F- ^# w& G0 K! V/ ]
) F6 N* }& l7 _0 f6 N8 E( e- private RenderType getLayers(String texture, int light) {
( n3 h) p l( P - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));6 }, l6 U& b! T% }+ h y2 A _
- }" o8 ^) T M2 a' R% f4 i& f
- $ \* i& L- k1 {7 G' h: z! ?; c
- private RenderType getLightTexture(ResourceLocation texture) {
: y7 A4 M. ]' h& ]) J/ q6 c3 M - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
`8 S2 i+ S- k" N x. K3 r( y - }
2 C# x5 w9 G+ [0 t( z+ T - Y' Y; M" V7 W, B/ X9 z
- private RenderType getTexture(ResourceLocation texture) {. q+ e3 p: h d O/ Z2 \1 o' {
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
& J D, a8 L; H - }) @. l6 s& y8 ?5 K/ V i9 X0 n
3 H- h; h% x2 w8 `7 t- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {$ y: U5 b& P2 [1 ?! @$ E
- if (cache.containsKey(identifier)) {
5 h/ U! [' C1 z1 N, H! ?5 w8 p - return cache.get(identifier);
4 l; @& f0 N( @% |7 Y2 A5 K - } else {
$ T: q9 B) w( q1 u+ ?; s1 D" j - final RenderType renderLayer = supplier.get(); \+ S, x8 q% j9 h2 f
- cache.put(identifier, renderLayer);
5 Q3 G6 y# H* u h$ Q& o - return renderLayer;
g3 [# l) o! ?& Y' A - }9 i7 [" n" X, s5 T/ e
- }/ W. J: f9 s( v, C
- }
复制代码 |
|