|
|
1 V% S- h6 `- @" l3 G0 Y
行,这个怎么样
0 t8 m, h) i/ c- F$ a6 S- package com.xhg78999.mtrfac.render;% w% K d! q# y% W4 t
- 3 N/ a4 w% ~% x8 z4 H
- import com.mojang.blaze3d.vertex.PoseStack;
) i5 @/ G7 {' s, m: R) | - import com.mojang.blaze3d.vertex.VertexConsumer;( X$ y! d, H4 s- F1 f
- import net.minecraft.client.renderer.RenderType;6 G) y: r6 ~. D5 {+ s
- import net.minecraft.resources.ResourceLocation;- G9 Y7 O7 j( a
- % E4 | `' \" s
- import java.util.*;
0 m. p* Q6 `) D! |: C7 [
- e$ D% L( E! @) y; s- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(+ @( I; Y J4 P
- 2 r o8 }+ d& n
- public class LineRender{
( k7 j ?5 N. Q/ Z1 C - private final PoseStack pose;6 B8 @" b9 E Q7 z: \/ g
- private final MultiBufferSource source;+ ]) |& G3 x% B X: V
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();9 P, h7 w$ a# F; p( h2 T
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
* s+ n5 D# z1 b+ T6 m6 \2 G - * [- A" X1 q( A" ~7 a( m
- 3 h/ t' e. b; [0 \' a
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){) b; ^6 e( Y! a3 [
- if(x1 == x2 && y1 == y2 && z1 == z2){5 @) E O+ x/ h/ e% E
- return;
3 I3 {' E6 M" z4 e4 Z; V0 e0 P2 y - }, m# U2 G' D7 o. _9 {1 g3 n% W; g' W
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
9 s: b' y5 `2 ]% d - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");' S5 s# i4 s; ?9 o% z' _2 x
- }" k9 R1 r5 B' g: I
- pose.pushPose();; T! _: V$ x2 l
- final int newLight = convertLight(6);
9 R5 {* N/ D* y( _; o - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));1 B/ ]: S8 D" I
- final float lineHeightSmall = (y2 - y1);' q9 m# K5 n! k& r( N7 n# F: B
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
; n8 H' Y0 m% X% a9 V8 C- l! } - pose.popPose();8 t6 F% r T, ^' p* u7 B4 \
- }9 [% ?: G: Y) l; G9 K
- / [: f0 P2 i, G u% m( n
- private RenderType getLayers(String texture, int light) {
! J" ^6 s' Y" G - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
3 c9 D9 ?/ ^6 {0 J# b - }2 m6 x( z, j3 G, I5 Y, [6 e. o
0 K% h n1 o/ a2 p+ W+ H& E: m- private RenderType getLightTexture(ResourceLocation texture) {
$ x( U& C9 y2 _# B - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
+ J$ d, m7 i4 x9 o( Z - }
) D8 U! H' V. a. a+ b* f" p
4 X* W0 C- W7 q; u2 {% z% ?- private RenderType getTexture(ResourceLocation texture) {2 N& c7 M5 e' z: ^
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);* H6 D1 d7 ?8 P! i- g. E) K& I
- }
: K) x' \% I* M9 t Z) b" J7 l
: y3 ~- p& m; Z+ I0 f- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
9 V* E& R/ k6 F% p3 Y/ J - if (cache.containsKey(identifier)) {
2 \& r" |! q6 u: X' N9 e- P$ B - return cache.get(identifier);
4 [& w6 }) d3 h j# B - } else {9 I* H# Q: g V" C
- final RenderType renderLayer = supplier.get();% U7 P3 O; u& _# Z1 f! L# t
- cache.put(identifier, renderLayer);+ E* f9 [% a0 v8 z
- return renderLayer;
* a' }5 j+ T1 e4 N$ o0 w j - }1 p7 A0 v0 q% J5 S4 I$ q& U
- }
/ ?$ z% L7 r+ k$ B - }
复制代码 |
|