|
|
2 ^6 }0 C3 h. n, V _6 X
行,这个怎么样3 p! [" I& u; f! @# ~
- package com.xhg78999.mtrfac.render; j: {: w0 i8 J2 |5 l: P# G6 \
- ( ~* d4 A8 `9 ?+ R
- import com.mojang.blaze3d.vertex.PoseStack;
; Z$ R& f% r( C! u5 l9 A8 y - import com.mojang.blaze3d.vertex.VertexConsumer;9 N, X2 s$ T: J! U) o
- import net.minecraft.client.renderer.RenderType;
6 W/ {/ i! d2 [' C% H! h: P. b, Y3 d) ^ - import net.minecraft.resources.ResourceLocation;' t b. j0 i8 |2 y q& x
" x! u! W; N( `- import java.util.*;
9 Z0 j& p' c6 U - % H$ C. \# J0 J m' e
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(+ \7 m( k$ }1 b: [; ^
) l W& J! P$ A2 W+ Z- public class LineRender{. P+ b* m- f- t# C. ], g/ C0 b6 B4 @
- private final PoseStack pose;
" M; O+ J! U/ a& B, A- O9 X - private final MultiBufferSource source;2 f& I3 `* h, ~2 r: N
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();/ c0 t1 V) ^1 l2 P. F7 h
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();) d& p- H6 G3 n" H3 x$ h& ?
- , d$ b |# a9 h* L, S6 U0 ~ M( q
- w% b' }9 e/ R1 ^- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
J* _: `! O: E, j6 x" w5 v; z - if(x1 == x2 && y1 == y2 && z1 == z2){
' ?- X/ `' @- J5 j# @% H$ D, o - return;
5 |6 F- x' ]" f4 e# [ - }
* o* X' m0 G2 k' V2 r - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){/ F: @% o; _0 R, R' T5 H7 K
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
& D r% ^, }" _( j( l+ d - }! @5 H1 y4 {* B: D$ R
- pose.pushPose();* g& G# b3 [% b# }
- final int newLight = convertLight(6);! M: l$ a* `$ {& A: P
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
) q7 }# ~/ u+ Q( A5 s4 j6 Z& q - final float lineHeightSmall = (y2 - y1);% v6 x+ ~2 ^* P. H
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
3 i7 C; C1 o: m - pose.popPose();! W5 ?% a2 M" _3 u( q6 q* d# n4 f7 W5 d
- }# i/ p+ w( M O/ n, X
- 4 Y2 J( S% t6 _, f8 X, n) v2 t
- private RenderType getLayers(String texture, int light) {
' G% t0 Y( P" a/ K3 g2 I! c8 F - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
\/ x; _' u! G% |7 j& O" k! O- Q1 l - }; k: Z: V6 g. P
- 8 g! V3 Q- K/ B( ]% W
- private RenderType getLightTexture(ResourceLocation texture) {6 | v, H8 C' S) d' Y& g
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);% q/ w$ d( c! ^ ~2 I
- }
& }) y$ q2 f& x3 J
+ y$ O8 P. [( l7 [- private RenderType getTexture(ResourceLocation texture) {( k1 M/ l: I3 G
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
' e8 u0 q: ^* R; A7 Q! ~ - } Q% o) ]$ h5 ~8 A: ^2 A/ D' P* m
- % P( I) c# }; Y& j( K
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
* N2 L( H- u# P( o& r/ x- a - if (cache.containsKey(identifier)) {, W+ ]$ D! n: n. N. |
- return cache.get(identifier);
/ b. ~; @ W7 k9 E! ]/ @ - } else {% ?. G3 k0 y2 l F# c
- final RenderType renderLayer = supplier.get();$ p5 a1 R/ Q9 k% d( s
- cache.put(identifier, renderLayer);1 ^, b9 W( A2 T$ W9 u
- return renderLayer;2 [6 ~. C9 ?6 `8 L, ^
- }
. ?" ?# m% O9 A" s/ m* j - }
! n# f7 p+ N) Q Z* {5 V% Z/ L _ - }
复制代码 |
|