|
|
- P4 `6 f4 y3 {' K* j! l' ^
行,这个怎么样
8 |# O. X; w" ~' _% P1 g7 Q1 A- package com.xhg78999.mtrfac.render;
: D8 `) |5 s# `
5 Y; R4 v8 m3 }2 H7 I0 O6 B3 n+ ]- import com.mojang.blaze3d.vertex.PoseStack;) V0 E7 T7 U* K8 I7 A
- import com.mojang.blaze3d.vertex.VertexConsumer;
* M- S. M7 e8 ~3 q9 T# G- ^ - import net.minecraft.client.renderer.RenderType;& n, I$ d) z, ]+ X# C
- import net.minecraft.resources.ResourceLocation;
0 h5 B0 v; ? r0 I
, z! z( R! E- _1 V o" c- import java.util.*;
9 k- Z/ ?/ ^2 o8 x1 |
' a B2 ^' J! }7 T- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :( \* m) S9 U) \9 i) K% j
- & y+ G* t8 c l/ ]6 t1 c2 s
- public class LineRender{, L+ V3 B; n6 Y( e4 a3 ^% r) c% y
- private final PoseStack pose;6 x) B/ k2 f' V# J2 B8 ~' Z
- private final MultiBufferSource source;
) v* H D* |% M1 [0 g& N - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
T% U, S' K0 m# D% r3 o: R - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
6 G% p: z9 B; B( t4 O - : ]' M$ n- ]: {! Z. M! l
8 e+ @. E8 i1 i3 F- b- m- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
" L+ }6 g. I7 G$ Y# d - if(x1 == x2 && y1 == y2 && z1 == z2){) a( h5 u8 a3 r5 v8 e: f
- return;% w2 ^- W. c" J
- }
% S: }* g" L6 {. x' i2 }+ n- M _% j* y - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){7 \( J9 t- l6 s! w2 m0 c# g: A7 [( R
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
/ s6 X; p6 f5 S) u& h7 y% B - }
4 O0 }( V* F! r ^; o. x' `* i - pose.pushPose();
/ I7 D6 W2 I4 Y) p4 b( l3 W" O - final int newLight = convertLight(6);
2 h/ {' D4 r* x% ], Q2 ~2 t( w - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false)); s2 ^' V3 N' U q$ ^+ N2 g7 A
- final float lineHeightSmall = (y2 - y1);; C `2 J1 p' n2 K3 h9 z# m) h
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);- r4 [* M; T, B
- pose.popPose();
) e, L$ }) _' z- Y+ T6 o& s& ` - }
2 M- Z* Q2 V: W+ D+ K& [% J3 a - 3 o* M' I4 [# _% o* L( x
- private RenderType getLayers(String texture, int light) {
, e% X# T8 B. t0 V1 k& H$ [- { - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
" n. W# X9 p5 Y' f - }
l% Q8 L: Q' N
! s( s; j3 F5 _( F$ a- e z: |- private RenderType getLightTexture(ResourceLocation texture) {# B8 M+ R+ W0 l0 w' l$ L2 ~7 P
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);; c5 G* Y f6 M& p
- }
0 m6 O# D( H; J# O& { - 5 p; C* U* D) O, Z" j% k' E! A( U9 O
- private RenderType getTexture(ResourceLocation texture) {* M! e* u- g- r. F! S
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
, n1 d3 {9 }/ Z# x7 u: `3 O+ X - }4 }8 j7 [. i5 I* d
, `9 H. k( ?" O$ F- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {6 X7 @3 l# w% X W1 Q& u
- if (cache.containsKey(identifier)) {
; y# c2 T$ n: `# g; r' K6 v' T - return cache.get(identifier);
, r% j- C' }+ y; h, `9 f - } else {. M7 ~2 u" u& d; S5 ?
- final RenderType renderLayer = supplier.get();; b X0 E* q0 T' r
- cache.put(identifier, renderLayer);
8 {! y8 Q4 K t, \9 p/ ?/ }1 A; w1 S - return renderLayer;- K: L- E+ f9 s* }$ S
- }7 ]) J1 w. m9 v& e5 Z: D
- }
; ^3 `1 }9 d0 r& j2 Q - }
复制代码 |
|