|
|
1 o! l' \9 j( `: q4 l8 y
行,这个怎么样1 F! E' f- S9 ?6 @) O" _: U
- package com.xhg78999.mtrfac.render;" X' \! J* P# B! \
- # `5 I4 ^# i9 W/ T9 s( A
- import com.mojang.blaze3d.vertex.PoseStack;5 |$ h9 Y$ v! z. U/ R$ M# G
- import com.mojang.blaze3d.vertex.VertexConsumer;
' w8 ^ z' t& B8 Y - import net.minecraft.client.renderer.RenderType;
5 `0 q1 g+ o! r4 H- G - import net.minecraft.resources.ResourceLocation;
[3 F( T, `3 p' u - . G; L2 ^3 P: \
- import java.util.*;2 F( C6 K6 z6 O. A
3 K4 M" A% T! S% q: x- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
7 ]9 W$ `, _, z( ]- X0 y, d4 J - 1 X* n- X) Y$ q6 ]2 L' W5 Y
- public class LineRender{9 D! v( f/ d. h0 `' H
- private final PoseStack pose;
+ x1 U: F. N2 Z3 h- Z3 {3 ~0 E$ k - private final MultiBufferSource source;' E) Y2 A+ G. b0 O
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();8 x0 `& T N; j) G+ Y
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();1 o. H" L; d' {
) s9 @6 W% X, Q+ z* K6 @8 f
" u: \& W/ H" k& C9 i _0 r- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){ O' L) Q' \4 c, P5 ]
- if(x1 == x2 && y1 == y2 && z1 == z2){
- j; V4 F3 `- `! Z. Z ]" s - return;/ ]% U7 h2 g$ [7 |1 R
- }
7 [* d. r9 r) U- [2 l( Y: P9 | - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
, N3 |2 a! L. h) z - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
" x/ |# { {% B2 A: n; M1 | - }
3 _* {* n6 P2 x/ m' x7 ^ - pose.pushPose();
( \" o6 [ _4 X7 V8 U/ b - final int newLight = convertLight(6);# ?/ v6 ]$ Z. m& e
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
7 S; {* u4 b( x/ C - final float lineHeightSmall = (y2 - y1);0 c1 ]: I, R0 Q$ O3 e) g
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
* ]% d) M4 r5 ^4 Z6 z$ m - pose.popPose();8 T' T& O* U7 N4 W/ W( N9 P
- }
" S: W# H4 x& a' ^ - ( r# n/ y+ N/ T) Q4 s3 |
- private RenderType getLayers(String texture, int light) {
/ N9 O$ a) x1 _0 ?9 \1 n - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
; h- G" T$ h( L: ]- v - }3 X$ V _" N5 Y4 P# L# h# b
- # C5 i- ^0 ~2 g0 O
- private RenderType getLightTexture(ResourceLocation texture) {
, U( E+ r, `! c9 r& |' {1 Z" D - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
! Y5 l( q$ O: W7 Z( I1 t$ F- G - }
) G7 [9 V f/ T$ M. ]3 A5 w
) S; P! x' F. o3 M- private RenderType getTexture(ResourceLocation texture) {
1 l7 |& i2 `* A* Y - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
- B2 y# c# T9 M R) \% g - }$ I) Z" j) E2 b3 W2 O
- - u" I( T, [' ?
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {5 m5 \# ^) b* o7 ^1 b# X. i9 _% U# ?
- if (cache.containsKey(identifier)) {
: t L2 n W0 p# C* X( T - return cache.get(identifier);8 l X- Q6 |5 E7 {: O3 S
- } else {' m/ h% m( B1 a: J- I
- final RenderType renderLayer = supplier.get(); L# Z5 v# I& h0 E9 E6 n" K4 g/ Z1 Z2 g6 Z
- cache.put(identifier, renderLayer);
* F- Y7 K Z+ U- E( z3 l - return renderLayer;
$ G/ ~! A& b) F; P - }
" V! {$ n- k! G# L - }
. p& k4 v( R, G7 n - }
复制代码 |
|