|
|
0 z8 _/ f; L6 T( c$ ^
行,这个怎么样
! S9 L6 P, U+ P! {, J/ h- package com.xhg78999.mtrfac.render;3 t8 ?: Y1 j9 a, A3 T! N* v, q$ X5 x
! o" e. W4 @2 ^1 f! @' `* h- import com.mojang.blaze3d.vertex.PoseStack;% w9 P9 H: z. A; ?2 O8 a6 I
- import com.mojang.blaze3d.vertex.VertexConsumer;
8 d9 D" w1 z, @) q5 s3 n- L - import net.minecraft.client.renderer.RenderType;! ] R I8 X) L) F8 z3 w7 [
- import net.minecraft.resources.ResourceLocation;
5 D% E$ c0 H& u5 I! i. D, U2 d - ; ~( Z$ n) n0 n# V
- import java.util.*;
# c K" V( m! S; @; h. p' Q6 O
- W V9 m1 J4 T+ O- A6 w6 r- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(% c, y# Z! a" \" P/ K
, U! P5 j/ Z( ~; R' M h- public class LineRender{
) e/ Q: D8 u9 T# V0 H7 | - private final PoseStack pose;
" H) P3 b2 W, s4 K- X4 Z - private final MultiBufferSource source;1 Q p5 W$ M* t6 S! @0 [
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
9 W% S, b! e2 N! _8 T1 B( L* ]4 _ - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
+ m5 l9 p @) w
* v7 z5 O9 ]4 q1 Z. m' z% F
: S$ w# i6 a! M& ^+ _8 \& t- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){/ W8 }, U6 g4 R2 o; k2 w7 b
- if(x1 == x2 && y1 == y2 && z1 == z2){/ S/ R( T, D S |4 n
- return;! l) l* Q/ J5 d1 H; A
- }
* w" N0 D' N r - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){2 I" ?2 E, }; }/ K8 d
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
' Z) q: E8 l% d8 b8 h - }" I1 u8 g# R+ F, K$ Q% k4 n
- pose.pushPose();
, |. |! L1 r& L - final int newLight = convertLight(6);
: ]7 P- L# ~9 s - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));5 M% l; I m( N8 j- R3 `
- final float lineHeightSmall = (y2 - y1);
, b; B1 X: W- m: o( ]( r) _& p7 V3 d2 F1 B - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);. m/ M6 S( z3 A Z w+ O
- pose.popPose();- @! V4 u& t/ a
- }) P& B2 X5 u+ m6 `1 Z' L/ `* Y
- ; T1 X7 I \: i9 e. k
- private RenderType getLayers(String texture, int light) {
3 k2 x! g6 o6 E4 [ - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
: n! L2 h( b; g9 e& _6 Z- O - }. E: J) ^" W" b! a, v$ s7 c" \
1 }$ ?( ?1 ~. ~0 R, I3 x6 @- private RenderType getLightTexture(ResourceLocation texture) {; y" ?- Q$ Z* i- O2 {, q7 }
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);- W5 S6 Y- X/ ~$ |% `' {9 K* V
- }' r: y- L* f3 U$ N* D/ N# u
- $ k! r+ `9 W! n V& W4 o* D
- private RenderType getTexture(ResourceLocation texture) {
8 N8 Z4 _' ~4 g5 J% \ - return this.cache(texture, () -> entityCutout(texture), CACHE_B);4 N9 N3 ?! R8 N; ?) h8 n
- }
, O5 |+ i2 a- U, L - 9 _+ l8 k7 `' ~, V
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {7 z; w7 c5 E% T
- if (cache.containsKey(identifier)) {
) r7 r( |1 C9 J5 R' @ - return cache.get(identifier);
1 J2 V0 \- K( a# r( X/ O, Q% y/ P - } else {1 }9 l1 l) |! Y3 k" o$ h+ X. C
- final RenderType renderLayer = supplier.get();1 b+ C {, M! {3 r: g+ e2 N
- cache.put(identifier, renderLayer);0 a0 `0 u. ?" h& X/ E+ S* ~
- return renderLayer;
4 C A: B$ l# V - }
# ?2 k J- `, Z% M - }
# @: g# \9 u4 F$ d! L' H7 O - }
复制代码 |
|