|
|
0 z K3 ^: S4 Q: M$ h' ]6 ?0 F
行,这个怎么样
3 O- l+ ?. P7 ^% b; u$ K! b- package com.xhg78999.mtrfac.render;
' {: m' Q# n2 [3 j7 p; Y1 ?
W- e& V6 M* S% C- import com.mojang.blaze3d.vertex.PoseStack;
4 [" R( v. U1 K" [( V - import com.mojang.blaze3d.vertex.VertexConsumer;0 h m$ a P) i8 M' h& ]) X5 Y1 R" ^
- import net.minecraft.client.renderer.RenderType;" i5 u! G4 K# Y8 X$ x
- import net.minecraft.resources.ResourceLocation;
9 d- U X/ o& b* N' l+ g5 i - 5 a5 t9 I6 @, W* a5 w
- import java.util.*;/ N! x g9 u7 b1 J8 k
- 9 x# D0 B$ s6 H4 _& l5 v) A; P
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(. ~8 r0 B# d9 Y3 I5 S/ \) D
3 d# H& ^1 q7 M3 H: ?8 I- public class LineRender{* ~, p& n/ H) n7 y% Z7 p& v9 z: y
- private final PoseStack pose;& ^* j/ v0 I: A' n! {# c
- private final MultiBufferSource source;
$ b% x2 B0 C; F9 m" @/ t% e - private static final Map<String, RenderType> CACHE_A = new HashMap<>();4 O( u, [4 B8 Z0 X
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
* t8 L/ m _ R, [ - ; ~3 c2 {7 ?. O& X8 a$ e& `
+ S6 F1 S9 {/ j+ C% z w- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){3 h% x! e0 \7 o3 a# p6 |5 M8 Q: x
- if(x1 == x2 && y1 == y2 && z1 == z2){: }/ u k) d( P/ @2 y2 F
- return;8 C( s& Y; f0 l. k) C
- }
2 A6 ~3 E& B, p2 U4 ?6 ^2 s7 Z8 ^ - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
- Q, }" Y9 V! o g) `4 @ - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");8 G1 W1 h* M# L& H' W
- }
) b3 O( }; Q' L7 W, N7 i - pose.pushPose();
0 h9 | u0 |/ n - final int newLight = convertLight(6);
7 D- b4 [/ D7 m0 |% K0 B - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));1 e8 E1 v% o8 e- v" c
- final float lineHeightSmall = (y2 - y1);
3 I0 c: p' Z4 J% l" r, } - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);4 p$ r0 S" Z L1 K( g& C0 ?
- pose.popPose();5 T) F& z2 K9 ~' {
- }
& e. s4 y* Z9 E" x' H4 Q9 P
. g- G' i0 @4 z- private RenderType getLayers(String texture, int light) {
. f" d7 @/ o. [; f9 T4 P! B6 `5 v - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
8 G) O( O' C2 C. | - }
0 i1 a0 b, n! C- D) j- `
8 c3 i; J( y/ ?- private RenderType getLightTexture(ResourceLocation texture) {
# `6 X1 C% |' Z0 N# ?) r - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
. ^/ K1 h/ C5 v% Q {4 d$ L& A& v - }
6 m- I/ X, f9 Q% L - ) N+ ?0 `' a5 @# |& d
- private RenderType getTexture(ResourceLocation texture) {; k3 `( f+ \( ?- t' E: j- C; }, f
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
' S( K& Z& z" t; m- w# X - }7 u- W$ u/ M0 x& l8 U
( _2 q0 }1 I) a% t% Z( {- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
! q" H( i; I! O$ t* y - if (cache.containsKey(identifier)) {' C0 ~' p% H3 ~5 e. b1 f
- return cache.get(identifier);0 E0 U5 ~- h4 C2 R$ L8 J: C* T
- } else {
8 }' |5 R/ A1 X4 M4 @ - final RenderType renderLayer = supplier.get();
7 X- |5 A- W/ H D. z - cache.put(identifier, renderLayer);
+ E) L6 ?/ Z- l2 B$ I1 w4 w" h* _; ^ - return renderLayer;
+ B5 j+ H- V5 j- A' a8 O& v* w - }( M" o9 r2 W2 \ z
- }
2 `1 I1 J0 @2 D% ? - }
复制代码 |
|