|
|
# A8 `! w* @; i7 ~ y' u/ r5 B行,这个怎么样- }. ]) v. ~6 U" G
- package com.xhg78999.mtrfac.render;6 s. q9 { a8 N0 B K
- , P+ S+ I" S' I: j% F- ?
- import com.mojang.blaze3d.vertex.PoseStack;8 B+ E( B! T# B: Y) N1 ^$ F
- import com.mojang.blaze3d.vertex.VertexConsumer;
! \1 q% A7 [- }- o- n# z* w - import net.minecraft.client.renderer.RenderType;/ u0 L' q! [1 g$ p! C/ k
- import net.minecraft.resources.ResourceLocation;; N- S% h/ G9 b9 {+ [5 R+ a' q, u
- $ y! X0 S) D3 ^ Y, `8 n: C
- import java.util.*;: f: c# a& k7 ]' p+ O' h
. [. C, y8 N' }6 \- y4 ^- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(% ?, F( m) P: F; p* t/ g( M B
- / D) A! e2 i- r" p
- public class LineRender{1 J4 H9 A" j3 x
- private final PoseStack pose;
' j3 Z- A( ^* j$ _ - private final MultiBufferSource source;7 J3 q1 q2 Z6 F$ m" `. B' i
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();/ \7 _4 `4 u @8 {* ]1 |
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();7 P5 e. U- j& D( U; b: F
- $ J+ }" Y# d* G) g" C$ \
0 y5 [1 V6 v* w7 ~* k+ W- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){, W) X4 c+ d( S; b, \* G/ m
- if(x1 == x2 && y1 == y2 && z1 == z2){
7 {2 L* q0 [! z$ o. I - return;
) C# G8 b, l# \$ o: @3 Z% e; j - }
& N9 G. l A9 C y* x - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
( C. L9 `0 Y$ M7 v4 H! Z - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");+ C# W/ F. {6 {9 R
- }
/ F4 _: b+ N/ N# D4 O - pose.pushPose();' ^: L1 `$ k3 t4 O, e
- final int newLight = convertLight(6);' X8 `& ^0 Y0 }0 ^1 C4 `' G
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
3 g+ m) a$ J! n+ f4 O0 S* o - final float lineHeightSmall = (y2 - y1);
7 ]( E. Z6 {: P# ~3 s - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
/ G5 _/ b( Y, Z: E& k$ u - pose.popPose();+ ~7 X) x' W3 O3 q' t j
- }
! E, V6 g* F* u2 C8 p - & |7 l( ~% z2 H+ a6 h
- private RenderType getLayers(String texture, int light) {; ]6 n+ ~1 S$ z5 j2 j* c1 Q
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));7 J! R- Q- O5 t/ K" v
- }
: {% `3 ~ R# }" C
3 N$ P. }1 F) j/ x; ~- private RenderType getLightTexture(ResourceLocation texture) {& W+ s3 b# _3 g4 r! V/ E( T0 J
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
: k) y2 X4 F# a5 \9 u0 } - }( u$ g+ e, @3 k& R$ D7 H4 S
- ; F, G: A& z, P+ `; K7 R- ~
- private RenderType getTexture(ResourceLocation texture) {
6 m& m, S1 j. d, D2 ^( A - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
+ @( [# n" |( J, x" A( s - }
+ t0 |1 W6 i* F
3 B$ J9 p4 d/ b8 }/ H" X- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {8 c, E1 H4 Y0 m6 J
- if (cache.containsKey(identifier)) {( E) n& j# K5 J9 e
- return cache.get(identifier);
3 W' A( B& H9 N* j5 c - } else {: G+ k* P0 f7 V1 z5 w) @: N8 g
- final RenderType renderLayer = supplier.get();
- d' j6 O' B" i; y - cache.put(identifier, renderLayer);3 m6 U4 P. m2 _
- return renderLayer;
" A- p1 o) q9 k' W4 c2 g D. Z2 @( D/ v - }
3 C' Q! p7 X1 |+ c# R! v - }
2 j% x; o7 {0 Q! c6 ~ - }
复制代码 |
|