|
- a, A- Q9 W1 f1 |% g行,这个怎么样4 i8 o2 ^' s* D- x9 c, E
- package com.xhg78999.mtrfac.render;0 @8 j; b' ~- O- S: S( n) h
& H+ C" G* x! B/ J( \7 I0 w- import com.mojang.blaze3d.vertex.PoseStack;4 K7 s- M3 w; |5 u
- import com.mojang.blaze3d.vertex.VertexConsumer;" l7 o% b! b3 {1 s- Q) t
- import net.minecraft.client.renderer.RenderType;8 o! S; I4 @' j. m! B3 z
- import net.minecraft.resources.ResourceLocation;) N2 }, D- Y' K1 w! [
- ( @6 d6 g/ F+ }" T; d! V
- import java.util.*;
9 v' \) }2 r% q% C4 l
4 B' ~3 }4 X, Y7 _& l- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(4 ] m3 J4 } d, g3 M
- : d* ]- g& v T7 M+ S
- public class LineRender{7 o7 J' J: e8 M3 _. f
- private final PoseStack pose;
' V' e' r9 M0 e6 I. E# P2 H+ ^( v - private final MultiBufferSource source;
+ `$ b7 z7 k& B' I% | - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
5 E7 ?% {+ j3 P$ w" |: H# r" ? - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();; c2 q+ `3 O# M8 U9 N* w
- & v( G$ R" l/ d9 T/ M P
8 g0 n* \& K# V- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
. S3 M% }# }* n/ A - if(x1 == x2 && y1 == y2 && z1 == z2){
: L' X; u9 E4 J( Y% d - return;
4 g- Y7 [1 {& u; i4 A' } - }# N' `# _3 }/ i4 A2 Z' d
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){6 i# n. I9 E$ C$ {
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
8 e1 k& y# s+ K4 ~ - }
7 I) {: Z8 Q/ @) H0 F - pose.pushPose();1 {! S$ @' n/ Y3 Q# Y
- final int newLight = convertLight(6);
% b8 p a7 s6 J+ O5 V - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));: T3 L3 t, {6 Q4 D4 u
- final float lineHeightSmall = (y2 - y1);1 O6 _2 o% @- w) e
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
, r' B) o3 r5 G4 h" D - pose.popPose();
: u* A, }/ g/ n2 `# r; e - }
4 n! x0 t. Y! I2 { I- L( N) Z - ; x l$ T7 }! K" o7 J1 z
- private RenderType getLayers(String texture, int light) {' P( q2 j( P6 ^2 L- W
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
1 P0 X" K8 _3 w0 v) |& A - }
8 \( j5 J, j0 ~
9 D* r+ I3 ]; p2 I0 w- private RenderType getLightTexture(ResourceLocation texture) {% z+ V$ e3 A" B; `9 `
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);7 d" `& v6 E9 Q" Y, U# |& @$ @
- }! @; k7 I% O+ N) o8 w$ X% n. O
- 8 [( s1 e. M% n4 O% U+ ]5 i8 R8 U
- private RenderType getTexture(ResourceLocation texture) {
! L, R h* d+ O; I) l7 q - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
* ^- e0 J& S" E8 w - }
# H# u. X) Q. A3 @9 O
0 u/ D. `0 \7 G: P% a- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
0 O3 B& S! }. O. T4 e7 T* | U - if (cache.containsKey(identifier)) {
7 {& p! L4 @. a( K - return cache.get(identifier);; y, r# `/ b$ d+ M
- } else {
9 y. w) S3 x) O( M" g6 y0 R A+ ` - final RenderType renderLayer = supplier.get();
2 r" }+ i9 `9 ? - cache.put(identifier, renderLayer);
6 `5 C9 X x/ @! Q - return renderLayer;! t7 n" Q3 g/ w' [7 i
- }
. ~0 K( Q" [8 j - }
0 w. k' N& t) E6 d, i i6 T4 {1 \+ {& O - }
复制代码 |
|