|
|
7 H; X- B: \4 F% U/ P) g( r6 D行,这个怎么样
! W A6 k3 ?4 ?+ n$ Z% [- package com.xhg78999.mtrfac.render;( }( t- {7 @1 y
: y5 W# B+ ]; P7 c8 y7 o- import com.mojang.blaze3d.vertex.PoseStack;
' M, V1 Z5 x9 q5 x5 u" Z6 [ - import com.mojang.blaze3d.vertex.VertexConsumer;
; D, p7 Q# r+ a$ [ - import net.minecraft.client.renderer.RenderType;8 y. U3 O6 F& J3 I9 A0 t6 k
- import net.minecraft.resources.ResourceLocation;( @! Y- A( j5 o: t% {! ~% j \
: i* Z7 r4 O4 ^2 r6 `" E2 I- import java.util.*; K# A% R+ y; g+ H
- 5 O5 q5 [2 K3 Q$ j, @
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
3 P/ O n0 X- x - $ c& { @& i+ [1 f
- public class LineRender{
6 G- o+ [9 ]' l* o - private final PoseStack pose;- t. F C" G0 M5 C
- private final MultiBufferSource source;: N( c/ P9 n0 D, j/ N8 L+ F$ N4 F5 |
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();! h0 x0 p! Q; O5 ^+ R. o `# \$ M
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
' V1 {4 s/ Z/ k- {) X
" o+ R" N5 X1 `: U/ F; H- # G. d* X* \9 h
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
1 p3 G9 V- U" D! j4 q7 W( t - if(x1 == x2 && y1 == y2 && z1 == z2){
* \+ t8 }% o' ~8 K# O4 z: p7 | - return;
! C" B1 @0 e% m7 }0 H# c5 I9 _% D3 m - }
) K* c" o6 e9 R1 D0 y( p - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
E0 ~; {- e% N - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
: L5 a( W* i& o - }% c# O$ m* e' L# P9 }
- pose.pushPose();. e. g2 }+ ^, e! ?' j
- final int newLight = convertLight(6);
- x8 d8 t# Q+ z" X9 Z. m - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));7 Z& Z! `- q2 i- V& c
- final float lineHeightSmall = (y2 - y1);
& a; b% T8 C. N6 B$ ^$ e - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);3 x7 b8 S* @3 c" V
- pose.popPose();
+ Y" z: }: o2 T; i0 H5 M - }
8 r( e' `5 V9 f3 L @; b
. a: ]+ m- _! R( f+ j$ S- private RenderType getLayers(String texture, int light) {: w+ j4 I7 f" f2 ?- h
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
1 k: ?5 Q5 C: C' E' P- j' U - }
: I q& D4 x' \2 [0 r0 g
) g& n- Y- v v, t6 G. ~+ T+ y- private RenderType getLightTexture(ResourceLocation texture) {0 U, r; t) S* P1 d6 H5 @0 i( @
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);) d. |, q. z$ E1 q+ o9 t0 u
- }/ A$ G5 E( N; U1 o$ V4 U: |/ g* W
8 b0 ]4 Y0 n1 s. R9 w+ F- private RenderType getTexture(ResourceLocation texture) {2 C* {$ d0 D, b
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
4 t! y7 U! z7 w& ]) e9 b$ k - }
9 Y: Y4 p, J' }1 n/ \% q
% Q5 D9 ~' L. ?) f/ \- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
! |" ]5 l& d- q, o - if (cache.containsKey(identifier)) {
, x; e: T5 x' j9 e0 ~8 P. K* ?6 z - return cache.get(identifier);3 x" m& _2 V/ Y. P5 P
- } else {
' e- w; h+ S0 V2 K* | - final RenderType renderLayer = supplier.get();( a9 G+ l( K1 w3 p8 E4 k
- cache.put(identifier, renderLayer);( @3 E) `7 B4 K: f( X% p
- return renderLayer;, G+ b8 o' Z$ ^: j0 X& y& G
- }: z0 [ Q7 w w, n
- }
9 ?3 I4 r- Y& _+ M" H - }
复制代码 |
|