|
|
$ y7 s6 q* F$ Y
行,这个怎么样
( e. D! `) k2 ]2 g3 B- package com.xhg78999.mtrfac.render;" z9 \! t- v p$ \
- 6 u9 @% V' V% g; t
- import com.mojang.blaze3d.vertex.PoseStack;# C3 P2 s: w* Q8 F9 G- ~
- import com.mojang.blaze3d.vertex.VertexConsumer;
$ S5 R; j% T# m7 Z# w - import net.minecraft.client.renderer.RenderType;/ |$ |$ S" x$ L- X+ z3 M# @* G
- import net.minecraft.resources.ResourceLocation;' y; ?" F) H3 g' o
- / ?9 O1 N( v7 |; a! T1 E
- import java.util.*;
: f( O, f4 f' k$ C+ b7 v - " S' y! t: @6 V' ^# J
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
7 g- J& z6 ~6 e1 h - : {: W* ^( k2 `8 G
- public class LineRender{" X' R9 z. n4 F# |
- private final PoseStack pose;( q2 K# d4 l. _% z; F1 G2 D
- private final MultiBufferSource source;
5 Z+ D3 r. s- _ - private static final Map<String, RenderType> CACHE_A = new HashMap<>();$ a2 o' T! c8 s9 v
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
1 S/ {* B# \8 a0 W: Q
4 K7 E4 u2 A1 A# i- 6 P/ ?1 W9 u3 K2 `1 A
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){5 N$ i$ D) G T& C& b, v
- if(x1 == x2 && y1 == y2 && z1 == z2){
?9 s! F9 s0 H1 L - return;
1 M3 s4 b0 F8 S6 _& B$ ^ - }- A5 u5 [6 p O( L
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){* S4 k; k2 @7 \+ v
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");3 _3 |" F& F* y! f! r$ f0 L9 }
- }. C, {$ H/ {6 B
- pose.pushPose();
( O: `2 K( D8 | - final int newLight = convertLight(6);
; F9 d, W+ N e& v1 ]! I6 B! u - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));, T9 [% x- [0 D- i% O/ o, U
- final float lineHeightSmall = (y2 - y1);' k# z6 c. y9 u" g
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
8 \5 x k; I& {3 j; a - pose.popPose();
5 X- x" K. U' I - }
6 K1 p' g' S) F5 e+ I9 R - 3 ^, C. O. c7 k# M6 \- p3 H
- private RenderType getLayers(String texture, int light) {
4 G1 J" A! g4 ~ - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
! G- e, B/ d2 \% t& V5 b A - }
) p7 m# D) ]& g+ n
& \8 j4 [3 w9 N( ^, [+ q1 Z# ]- private RenderType getLightTexture(ResourceLocation texture) {1 k5 v) J. v' D
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);/ {; x2 z% Q9 d9 T; `1 m4 J( @
- }
+ v) N! n) T, c" x9 R
, ~/ c8 [6 Z5 P6 p6 |$ Z$ m- private RenderType getTexture(ResourceLocation texture) {3 `/ }9 Z7 `- f
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);% X0 C7 n" J P8 n
- }0 K5 @! {' K" l6 ^6 f4 J. Q
- 5 p; y) v2 s4 J1 y0 R
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
5 ]# ]# h1 e# Q/ K" C5 r1 g& d - if (cache.containsKey(identifier)) {( }, B( U/ m) }8 |8 ?5 b
- return cache.get(identifier);
! |' @ w) d6 G5 U - } else {# W/ o' o0 p8 }8 N0 I
- final RenderType renderLayer = supplier.get();) [" n2 Y6 f' Y( l+ K2 b8 v
- cache.put(identifier, renderLayer);1 Y; v% X3 A; `# p. d
- return renderLayer;* s2 _/ w, v z- \* X( L0 H
- }5 h( D3 ?* B5 L7 j
- }5 Q% S/ {3 Z0 @6 b; \- I
- }
复制代码 |
|