|
|
6 Y* k% c$ l' N2 ^7 Y3 p G
行,这个怎么样) i5 s/ t& P2 P: W9 K
- package com.xhg78999.mtrfac.render;! w% M$ O5 g0 B% b4 A. J( }& H
6 [& o5 `5 }; G: `) g; G- import com.mojang.blaze3d.vertex.PoseStack;( ~& S5 v& J( Z0 @1 `
- import com.mojang.blaze3d.vertex.VertexConsumer;' H' e8 \ o5 C; G
- import net.minecraft.client.renderer.RenderType;
5 E# Z. U: T' X# f8 y - import net.minecraft.resources.ResourceLocation;
4 a6 e/ C: E1 J
! ?' o/ k! C9 L; V. h9 H- import java.util.*;2 K R1 u) ]6 x. Z9 e1 G) c% j
9 X) V/ L7 o9 Q- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
8 X$ p- \& k1 z4 w8 a! ]
+ @6 O) { D0 b5 o5 z: Q0 R- public class LineRender{4 }8 ?6 P0 T8 D
- private final PoseStack pose;
9 W$ ?' C& z! T6 p( y1 m - private final MultiBufferSource source;$ @7 l1 i9 ~0 x+ q. }4 o* ?9 ^
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();/ }3 c8 g7 F3 n2 @5 _ o: ?/ b( _4 {
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();& S: k: [$ d, \9 M2 b
- ' V5 w; Y: {8 Y7 ?
- 5 ^9 t* M9 D6 |2 o" X- Z
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
. Z# e; d2 w# m2 S: i - if(x1 == x2 && y1 == y2 && z1 == z2){. T1 d) q0 c& U! i" q4 d; ^
- return;- H7 b( R( S8 l
- }8 Z3 X A# Y9 k% @
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){6 \" s5 Y- b6 T5 K
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
9 h2 |% V, ^9 } - }4 A3 z* y6 }" Q& X, K
- pose.pushPose();
% ]. H7 r3 L1 d2 D - final int newLight = convertLight(6);
& D; @% e3 x9 L: r# I! _2 p - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));$ p; @1 K9 X- e
- final float lineHeightSmall = (y2 - y1);
, w1 r) t; _, K P. g4 B - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
/ D q% i; k' _$ Y) B/ U8 z; p$ l - pose.popPose();
6 I. M+ h7 V3 ~( a" b1 R8 S0 T1 h. r - }+ Y4 j7 d, w2 j$ f0 x
- 8 N% x8 p2 U+ g
- private RenderType getLayers(String texture, int light) {
9 l/ x, z* ]) [# }$ X6 g6 @ - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));4 }( T% `' b9 a8 C9 A
- }; N" _, l/ R2 i7 \
/ a0 G8 n4 {- R- private RenderType getLightTexture(ResourceLocation texture) {
; _' v! N; ~3 X. j - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);( W0 F$ E7 G b
- }
& _; s) f3 z1 B& b; B N1 N, {+ a" z
& S9 k4 v8 O z3 j2 `) g; D" ?- private RenderType getTexture(ResourceLocation texture) {
1 E6 `4 v2 I8 o - return this.cache(texture, () -> entityCutout(texture), CACHE_B);) f% Y2 N, T: y; {
- }
" }$ _$ d% Q+ \2 M3 d - ( u0 B2 L1 t5 w, }' E
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {2 u* a, R' q3 l U U, Y
- if (cache.containsKey(identifier)) {
/ ^% A1 `7 \2 u( C5 G - return cache.get(identifier);
9 m& J1 v" a- ~7 Z4 \7 s - } else {
- ~$ ` C P# W" N- S5 M; ?# l - final RenderType renderLayer = supplier.get();! `8 K* L' W- s- o$ ]0 r
- cache.put(identifier, renderLayer);
$ g! g1 c" s9 L - return renderLayer;
% H$ d) q& M, l* H1 w6 n - }$ f* l4 y9 w* f' A3 f
- }
& L' s. ]8 G# T/ ^9 p - }
复制代码 |
|