|
|
; K% j6 l9 T5 t2 u
行,这个怎么样3 u5 @1 G3 D W6 h" p
- package com.xhg78999.mtrfac.render;
0 H2 W w" g1 z - - K2 e# V3 l% @+ J+ C, u# N3 |
- import com.mojang.blaze3d.vertex.PoseStack;
! G/ _- P7 ^ N) t2 _! E - import com.mojang.blaze3d.vertex.VertexConsumer;2 u1 A; c X$ a3 u
- import net.minecraft.client.renderer.RenderType;) M1 W: |. t$ P
- import net.minecraft.resources.ResourceLocation;
9 Q% n8 B5 @" a) e5 H7 _ - 7 ]' V) j4 a& i! ]7 m2 \$ P
- import java.util.*;
. r: _1 n& l; X, F% M
4 @5 U, J5 P# V0 e5 H N5 g- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(' `/ o! `1 Q: F% D9 y
- 7 U' p. ?' }9 Q5 s
- public class LineRender{$ f' }2 q, r) R/ H% S
- private final PoseStack pose;
) W4 v! {& m( u G+ ~ - private final MultiBufferSource source;
& h4 F6 P" w6 E% E* n - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
5 Y3 }+ |! G4 F1 n! T( g" r/ ? - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
. B$ ?3 `$ Q {( s8 H3 ~
. x# x' J! q; b% y% }
) c/ `2 j% [* E- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){2 ]# `6 h/ A- h9 @# X0 S
- if(x1 == x2 && y1 == y2 && z1 == z2){
! U; l8 |6 A. o2 ~8 m, c. v - return;: A0 g- R- j a! A( j2 P) K
- }- l" P `( Y0 R
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){' M0 E) `3 I5 Q4 h' i3 V
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");( O1 W8 p( a; J
- }# f! X; w# w$ q+ U1 p
- pose.pushPose();
1 `, Q- h2 H- A8 C: _ - final int newLight = convertLight(6);
1 A7 r- B" j# T$ j/ }' I; F! W( l - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));$ H0 S/ g6 Z1 H, t
- final float lineHeightSmall = (y2 - y1);$ b6 F& k3 O' R: O6 H% y& s
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
; @# D/ h( x0 E# Q' V1 ~, L6 } - pose.popPose();
& x' n1 |- l: i4 A' \ - }
9 X; P; `* |6 }, J0 q
# v1 j. S8 }' P- private RenderType getLayers(String texture, int light) {
7 G0 F3 ^3 g& P# D% i - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));& u* x2 G2 f' Z
- }
; d, ]' k) y/ w* Q0 p; V% C - 9 g! S/ I% g' S' s+ E& ?; g7 V
- private RenderType getLightTexture(ResourceLocation texture) {
) |% u/ h* I7 }% v7 S' j5 N* U - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
% c4 w, z d8 E - }
. I9 ^1 V/ C* G% n; T" p6 @
5 ?" |% J& B7 `" n# E- k- private RenderType getTexture(ResourceLocation texture) {8 \% y1 H6 G' {: {$ G
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);( d! J# }9 \7 m! D# F; F
- }7 r3 a6 F) D0 M$ m; I4 W
5 i9 d4 ^& @' [& @- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
# N5 M; C5 l: L0 g. ^6 S - if (cache.containsKey(identifier)) {
* R9 O* e" J- c* ^8 V% N - return cache.get(identifier);: C, }/ n6 A# _6 L ?7 A
- } else {4 x. a7 B6 @; h& R f) K4 X
- final RenderType renderLayer = supplier.get();
% \' g! v% B" [) L, s' i9 }' c - cache.put(identifier, renderLayer);
8 ?* d% T. B: e) [ - return renderLayer;
6 B7 `9 { A0 I8 z: _ - }" B9 F) q3 U- _+ C
- }" [+ F% }6 H$ A. h+ N ?+ H) A% `# ^* }
- }
复制代码 |
|