|
|
1 ^) |+ D# @% v9 ]4 Z# g行,这个怎么样5 N9 q" O) x- w" \5 Z6 C
- package com.xhg78999.mtrfac.render;
, T! x; e, @, s7 F. _6 ]
, T: j/ i9 t; t4 @: H; ~) A1 `- import com.mojang.blaze3d.vertex.PoseStack;) m5 v, u1 D4 H" d" I8 ^
- import com.mojang.blaze3d.vertex.VertexConsumer;
6 D! k3 @7 G- r) |# z4 k - import net.minecraft.client.renderer.RenderType;
; K: k9 u v3 o/ ? - import net.minecraft.resources.ResourceLocation;1 _2 w: V, N/ B& I2 P
3 a# g( Z" j( Z& x5 V- import java.util.*;
o: v* @, q# G# i - ; n) x2 A9 L- I5 F$ \+ k: Z
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
2 {. W- y R; \2 O9 B% R! | A - - m- x! z. T, ` z6 A! v3 y
- public class LineRender{
5 H7 p' w" O4 r1 E0 |* f7 Z - private final PoseStack pose;1 a/ t2 n4 o- {* B( G
- private final MultiBufferSource source;8 p/ v Q! X! M+ g9 x! |
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
6 o; g' N c7 N! A6 L - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
, \3 g- v' `1 N
" n; T( c" S2 S
) Z W( g& b6 X6 O# R" p' M2 C- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){ E7 }- \$ j! S! S- q, ~
- if(x1 == x2 && y1 == y2 && z1 == z2){$ r$ f2 R( p/ ?, x( J! f4 e
- return;/ Q; k+ ~9 G: Y4 X# U) G& n
- }
! ~( o& j+ N# w! F2 o - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){; J2 Y! ] b* X z7 t5 U3 d% A
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
( {" n. C# Z; ~7 k - }. f" E7 }( D5 |5 n7 ?2 T% D0 Q/ |
- pose.pushPose();7 }, Y! ~5 {6 O" s
- final int newLight = convertLight(6);
$ q. R, K( w7 O; F( y - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));2 m+ k, f' d" x/ o+ r
- final float lineHeightSmall = (y2 - y1);" S/ b( N+ Z+ ? L
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight); M) k5 `! _! h2 j4 o4 e' H
- pose.popPose();
: n' u: P( e& j( K/ l& R. P - }3 a. O3 r4 u1 h# w5 \- G6 R3 Y
- 5 V5 D5 l$ u5 I1 \: k
- private RenderType getLayers(String texture, int light) {
& N5 ]1 e, ?7 q5 r S( r0 @& |* e - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
1 _9 A/ X" C; G6 P - }
' ~% ]8 D- g4 k/ c - : v9 t7 K" n" S w& b c, b& Y
- private RenderType getLightTexture(ResourceLocation texture) {. l" u* M7 b' \) H9 Z/ Q4 D
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);: n% R+ S; `, j, ?7 S# @8 C
- }
6 K1 n: B, o+ O1 Q) q/ a% M9 S - : v$ _ d& n8 G# E! Z: f" B
- private RenderType getTexture(ResourceLocation texture) {% L, m7 `, ~+ K0 Z8 G
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);9 P0 I* O6 Y# ]) Q
- }
8 B+ y; W+ [* f, w - , H! z! Z& Y+ ^8 v4 K
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
& j' _! p, s6 U - if (cache.containsKey(identifier)) {
( a4 u' H8 c$ V" L - return cache.get(identifier);
* z' N7 W( S2 V% e( \1 ~) K - } else { @( T" N6 ?3 d0 ^
- final RenderType renderLayer = supplier.get();
3 {5 T; {" W6 w - cache.put(identifier, renderLayer);- u3 @5 X% r# D) G3 w
- return renderLayer;
9 ^( t5 y+ r3 `. B; z2 Q( R - }/ t# |2 o6 C, b" P2 c
- }) r. E# x- J a3 q
- }
复制代码 |
|