|
|
8 _- n# V& K$ n l! r
行,这个怎么样
W( q3 F& r3 @; u/ j0 l+ x- package com.xhg78999.mtrfac.render;
9 Z2 D7 b8 E% M% D - 7 U! U A7 ^. Q1 m
- import com.mojang.blaze3d.vertex.PoseStack;0 P( s4 C; ?% T0 B" z2 Y8 n
- import com.mojang.blaze3d.vertex.VertexConsumer;3 w" U* H4 h3 D! ]7 f
- import net.minecraft.client.renderer.RenderType;5 P3 Q$ M& \5 c4 c9 ~* l0 j( m" M
- import net.minecraft.resources.ResourceLocation;# _( A1 S6 R9 j; Z+ P. W
- % I6 _7 e9 X6 b O+ P) Z7 j
- import java.util.*;" A% X& p2 K' m; _( `3 u/ s* d
: H' k3 m5 K' N7 }- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
" X% Y8 |) E; a3 s, k" i
( I2 Y! w; e. G- public class LineRender{; x& F7 Z6 p _& X
- private final PoseStack pose;
% s) M2 `5 z# i+ U: k: b - private final MultiBufferSource source;
. a: r, H$ G& P& j4 R1 Z - private static final Map<String, RenderType> CACHE_A = new HashMap<>();& T8 u0 {5 U# F! N+ k4 ~6 H; o
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();2 j2 O' Q# u9 y2 s% `, x# p
( N" B( Y* K4 U& j
( |. @. R9 F; n" f3 A6 V- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
8 g. g. w/ c) ~2 b( } - if(x1 == x2 && y1 == y2 && z1 == z2){
* W% b6 R8 ?( Z6 X& [0 x3 l - return;
; l7 Y2 I5 | [' E& S/ i" u+ j) m! @ - }1 W, d" [4 S A+ X- {6 q4 F
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){ z3 L9 G c# e3 ?! G. z
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
D' c$ L5 N$ P0 W. @1 j - }" A5 T1 z: L! j& ?( R- ?: u
- pose.pushPose();% p" l2 F2 q2 b, r$ E' t
- final int newLight = convertLight(6);( Z3 C- g# U- I2 G* P8 D
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
; p9 W( X4 w2 C3 L1 s - final float lineHeightSmall = (y2 - y1);
. q+ i( v; z: k5 g - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
6 N/ w: O! H% H r r' y6 k. e - pose.popPose();
* e. R \! ?) d/ U2 | - }7 b7 f% Q. Z$ J
4 A* a4 B; j* n8 f5 P! u- private RenderType getLayers(String texture, int light) {7 k N1 U; p8 G- t. w
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
/ J }2 n$ s, t' y& r$ O+ p) O - }* B/ E; k# S! A% X
* l( D" S* A" h" r5 K2 T- private RenderType getLightTexture(ResourceLocation texture) {
0 u5 W4 U; z: Q; @- M# A1 q3 p7 X) m - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
[0 U9 r% h3 R0 A8 ^ r - }$ W8 i9 _; ^9 P, S- m5 U# ?
- 0 V$ o" V' Z/ n% ]4 J! A7 C
- private RenderType getTexture(ResourceLocation texture) {, t7 ~: e( J) f1 r/ ]5 b/ {
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);1 l1 F4 Z- l* H) ~# t0 u
- }" j& l. v5 i1 B2 P
- 1 U6 Q9 c8 c. u# y" E* A9 Y8 p4 | p
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
) l' O$ E" i0 w: ^ Q - if (cache.containsKey(identifier)) {: i5 U/ l; A+ q$ h$ O- k
- return cache.get(identifier);( \$ a: D' R2 V8 E1 ^
- } else {5 W6 \1 j0 x2 E$ g$ |
- final RenderType renderLayer = supplier.get();( O% j4 v# I. e \
- cache.put(identifier, renderLayer);
, j' m; F( F v* ]6 w! C" r: _4 m6 l - return renderLayer;, l9 X, c* b8 @! o+ Z7 Z
- }
2 E# m0 F7 C1 O3 h/ v5 }6 h - }
8 a9 o2 P$ C1 G, ^3 ~0 r - }
复制代码 |
|