|
|
3 \6 ~7 r7 M: `3 m- c! j8 s& f行,这个怎么样; g7 P6 P, _2 A7 Z* P3 z! l
- package com.xhg78999.mtrfac.render;
3 D0 D/ |" r; l# b0 R; W - m7 }7 F) D P0 s3 z! _
- import com.mojang.blaze3d.vertex.PoseStack;* }4 O2 J+ _$ e1 |3 d; {
- import com.mojang.blaze3d.vertex.VertexConsumer;& f* g: k! r, @9 U; C
- import net.minecraft.client.renderer.RenderType;
1 x' f3 A* C; }" p - import net.minecraft.resources.ResourceLocation;
" P; x2 I( q+ I, N2 X; j. A
/ {& J5 y2 ^3 k$ i- import java.util.*;
. L ^5 n( q8 e" q( ` - , V/ ?& r* B3 [: V
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
/ X9 I- g' {" l' I6 F+ D& P - 8 L+ l: P. p+ f2 g) \" U# y
- public class LineRender{
: i0 t: |4 [0 s: y9 ` - private final PoseStack pose;
- V8 `7 [, K( W - private final MultiBufferSource source;
0 T) i# E4 a& a5 @8 N- ]" V6 l - private static final Map<String, RenderType> CACHE_A = new HashMap<>();* v% D+ O- `3 C
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();) i, D& \$ ~' t! _9 H+ K0 P
* B _. I9 B% m# E
# F7 k) m, H/ ?- M9 C; h7 @. G- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
# @9 a6 P& r8 v8 k, l - if(x1 == x2 && y1 == y2 && z1 == z2){
; a. \4 }% x) I' {/ J - return;9 \: Z! c9 a$ C" `8 b3 V+ V! I. S
- }# t3 c, j2 M2 b+ @/ f% s5 ]- p: K% S
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){& q8 \3 i3 w9 J. S' v! ?
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");( N0 ^6 m% E: S& E: y
- }
1 P+ m* J& a3 }- {( q3 ?9 ` - pose.pushPose();, ?, ^3 W; o4 u' L3 r
- final int newLight = convertLight(6);
6 ~+ N1 B) _. i. w& F( ^) K5 i - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
( U3 p+ l. U& G+ e1 I" a - final float lineHeightSmall = (y2 - y1);; ], P0 j' W+ X7 Z
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
3 |# i7 ]1 b" b2 X* { - pose.popPose();1 [7 F$ Y6 k! ^6 G: d5 F8 E: ]4 m( a
- }, W1 J2 M$ }" v( \ f2 g k
- % r; z, O' ^5 [6 a* m; p; f+ M
- private RenderType getLayers(String texture, int light) {
% L2 s6 Y$ U, s- Z - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
$ K: W& f( v) r - }
: O7 d7 v0 e/ j( `# t5 v) J
5 {7 @4 L# w* O5 X& ]2 C3 ^. a- private RenderType getLightTexture(ResourceLocation texture) {
4 C9 [. G2 @ o* ]. v; N3 t - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
$ H3 o1 H8 u1 j, _' o: t - }
0 L5 r' j4 ]: l. u
5 i2 ~7 _; E' Z9 Q5 O4 i+ B( A- private RenderType getTexture(ResourceLocation texture) {
" ?$ s5 O9 U1 f7 ^+ }" a% Z$ v2 L4 u - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
; V6 ^1 n" B' n# | - }
/ z/ Y4 [! }8 T/ C& R
" T J" w# z" G8 \# c- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
' e. K5 e" C( M. R - if (cache.containsKey(identifier)) {, E0 l7 y% V0 W" [9 N! v% L
- return cache.get(identifier);2 r1 W5 k7 y: p8 ^& `/ T4 l" f5 \' r
- } else {! I1 c S- k2 P# F' G' y+ ? U; U
- final RenderType renderLayer = supplier.get();
, r) m2 q7 q7 S" j9 L } - cache.put(identifier, renderLayer);) y: N# h* \7 E
- return renderLayer;
6 M e" U. h2 ^+ J' y& O% p O8 | - }
$ C8 b3 B% T/ p+ p0 P9 V - }
8 W' N0 v0 c% M' f; c' \ - }
复制代码 |
|