|
|
" I* F; @& j/ ^行,这个怎么样0 k7 K7 s1 {( m# u, W
- package com.xhg78999.mtrfac.render;3 B1 F( M" ?; q$ |
- ; r) l( Y) S- [
- import com.mojang.blaze3d.vertex.PoseStack;
/ J$ J+ K/ P; n& J - import com.mojang.blaze3d.vertex.VertexConsumer;+ G0 q+ C/ P' r$ j9 [5 U: g
- import net.minecraft.client.renderer.RenderType;. ]; z6 d+ I; j. {4 W0 \
- import net.minecraft.resources.ResourceLocation;' N6 K9 e& f" u5 j( \( E% P- Y
2 x* \/ }/ P- P0 \- import java.util.*;2 V/ o* K# s, ~1 \+ G; b- k
- 0 `& ~" M' n6 I8 }. W. q
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
8 X7 {% v0 N5 [+ Y" o
1 b& V P( T/ o. M- public class LineRender{8 \8 V8 x r+ ?
- private final PoseStack pose;
4 P# m% V& q3 | - private final MultiBufferSource source;- r+ K7 `; N- v o$ `) m+ }8 N8 C
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
& T3 K/ W7 X9 W8 f n - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
1 j) O% A4 Y, C5 e$ ~2 W
- R0 K8 o' a' q, k3 S0 }. _6 ^1 X
) g& @# e; c, s/ R+ t- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
$ r3 ~8 w q3 Z' B ^ - if(x1 == x2 && y1 == y2 && z1 == z2){. n" F3 q" ^6 |8 b/ ]
- return;
+ D7 X1 D2 Q3 o - }
; W) c/ q I9 \9 D1 G4 M) j; h. ] - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){- k; T# ~. T& E+ }. P4 X
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
* N& Q$ H- ?, E& g( {8 i0 r. d7 K# Y - }
1 Q1 D1 S$ s- x/ _2 `! C: a& C; E - pose.pushPose();% p& u: m5 Z3 C3 W# _* m# D3 Y
- final int newLight = convertLight(6);
1 C7 N9 Q }% M1 W7 V - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
7 S5 K/ z! I0 D# { - final float lineHeightSmall = (y2 - y1);
5 h4 z4 v; U7 q `1 B4 u - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);+ E/ M0 X# s: Q
- pose.popPose();
! h8 M% U! E5 Y# p5 T4 b) U. K" K k4 K - }6 W) _$ |- A- ^
- : u+ Z( B( x2 r& e1 H
- private RenderType getLayers(String texture, int light) {
7 T; B5 k. } E" ~2 K% h - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
' M, ^5 }5 O6 j0 B2 C+ k3 y - }
+ S1 `$ f6 g, h* W; a0 z - ' t7 E7 R5 Q( b% g' b. H
- private RenderType getLightTexture(ResourceLocation texture) {
( X( Z: C& e' |9 J - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A); c2 [) x' ?: s1 f0 c
- }
6 L* e1 f5 e4 E1 t) j* t - - r) P* {: e9 U
- private RenderType getTexture(ResourceLocation texture) {" _! F j4 l, d- _2 V. p5 [/ y
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
# x" b8 `9 @" u) F+ v% Y( M5 u - }
0 B0 \( p9 ]' }( `! J' [7 H - & `* R r1 s/ D- e* [( A) A+ o
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {* i+ j' ~$ k% P( L; P' v$ N
- if (cache.containsKey(identifier)) {
/ v M) m7 J* B+ R7 Q - return cache.get(identifier);; g# D' k6 ?8 n7 V; Y: A
- } else {
6 m" W* Q( P$ M2 n, t% Q4 N) F - final RenderType renderLayer = supplier.get();. N1 {3 s* N0 p
- cache.put(identifier, renderLayer);
$ f( J, L1 C% \8 s) d - return renderLayer;, R3 U/ l0 k0 t+ c
- }
8 d2 u9 R1 P7 i/ |2 l$ Z - }
7 ` N$ J, F/ R/ F. G2 y8 H - }
复制代码 |
|