|
|
0 {, A: D2 f% y& p: q* y
行,这个怎么样
) e1 v( a' w6 y5 G$ B& l. Q2 g" j- package com.xhg78999.mtrfac.render; H$ L6 ]2 R: L8 j+ U. Z, w
- j8 r0 z- J5 S; Z/ P
- import com.mojang.blaze3d.vertex.PoseStack;! u3 I& [0 X# Q* z' H! X- }* ]5 Y
- import com.mojang.blaze3d.vertex.VertexConsumer;1 T$ Y( P7 @1 B7 N
- import net.minecraft.client.renderer.RenderType;! @1 W( w4 Q- ? X2 w( X
- import net.minecraft.resources.ResourceLocation;( ]* O! R7 c' h3 z, C
- / [ t. `% `; T4 t
- import java.util.*;
0 \ ]- S- V0 }* ~$ z2 W - / {- w( K4 O) t' v+ D6 i/ @
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(1 w- u! [4 k/ E: }9 {, Q
- 4 S, U' u! v/ D% E
- public class LineRender{
3 ^" P$ l- ?7 o- s - private final PoseStack pose;# S, ~ y: x1 o. Q$ Q7 r" K# |
- private final MultiBufferSource source;
* p3 j; N' D! Z* O% m8 T4 }' A - private static final Map<String, RenderType> CACHE_A = new HashMap<>();% ? x) T* I+ X, x
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();% i1 R/ g+ d7 V+ L& ~9 e
7 ~% e% A0 @6 h
' u' n+ p: y5 V; v9 ?5 h4 g- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){8 E9 P* E' w. i7 {# Q
- if(x1 == x2 && y1 == y2 && z1 == z2){
; ?; k6 z- d+ b; }! I( V - return;
- P+ ?* u8 M2 C$ |4 ~- r, } - }
9 K3 _9 Z( D8 U - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
+ ^$ i; W* Z8 w h - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");8 x! p; y8 R2 O) M# Y
- }. L3 _. i7 \! l0 c5 @$ Z6 ]9 A
- pose.pushPose();
{4 N3 O- ]) B/ G* v/ C - final int newLight = convertLight(6);
; Z6 M/ H# M! s( i - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));* f% o9 m5 A) \, z
- final float lineHeightSmall = (y2 - y1);
5 K7 o D% i+ d9 u$ e3 U - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
8 o0 P; u6 X+ t( P; k+ Z) d - pose.popPose();
4 B; P$ t0 k$ D3 ^4 { - }) F+ n3 O. {5 d4 @4 f9 V8 W
- 4 C2 {' l, h( o% n
- private RenderType getLayers(String texture, int light) {
& ]9 a" m; W0 f1 n% j0 l+ ?4 H( Y - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
' W2 h) f8 O! } U4 t - }1 Y- v% |- W) F' Q, `# y1 ^2 G& i" C
- 8 e: d* v5 F) s
- private RenderType getLightTexture(ResourceLocation texture) {; P6 R' { N- J1 Q& | Q
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
: e: _5 @& r3 W - }
) Y% B5 i# d* v$ ?) [- H - 1 w& K+ t& B# h: b8 l& K
- private RenderType getTexture(ResourceLocation texture) {
6 i1 e) W* o4 N - return this.cache(texture, () -> entityCutout(texture), CACHE_B); m2 \, N4 x4 o7 h
- }
/ Z, n9 m( {. A7 u - 9 u) B2 V9 @5 o- T; D
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {* L, A! D3 `% n* | j: _( X
- if (cache.containsKey(identifier)) {' I/ q3 e% @1 u; u# x% U, m
- return cache.get(identifier);, x* l8 u4 r+ o9 Y- D" f. f; V) x' B
- } else {; t0 b5 j" a4 [7 U( p
- final RenderType renderLayer = supplier.get();2 O; M% w( F0 g* A/ u& n
- cache.put(identifier, renderLayer);
D& Q3 d; F0 h, t/ u3 |+ H& I - return renderLayer;
7 p# r4 ]( Y' { - }: J! T2 ~% v ]
- }
& \! ]& }+ |" L1 s1 X: a - }
复制代码 |
|