|
|
1 o. y3 I% M4 B* G0 q/ h: ~行,这个怎么样( C% r' E2 T- j( d2 F
- package com.xhg78999.mtrfac.render;
+ e3 G8 g+ @7 p3 ~4 f- E - & R/ E- ]% A+ u3 h
- import com.mojang.blaze3d.vertex.PoseStack;1 O* _9 G! C, i6 P- `6 J* D
- import com.mojang.blaze3d.vertex.VertexConsumer;
1 l$ I* l+ M% j) `# x& E5 z - import net.minecraft.client.renderer.RenderType;
" W% B1 H- \$ x( s0 B5 I - import net.minecraft.resources.ResourceLocation;* a# q6 S5 j7 l
- : l+ s7 h+ _( D& b0 f T% C
- import java.util.*;, K; e, M) i+ \$ Y
' Z( U+ M$ J: w0 X- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
- H. }3 v: D v1 Y! o8 _
: H* n' q$ `. X9 d/ X- public class LineRender{
m3 b6 ^7 D" o! \+ Q3 e5 W0 a: ] - private final PoseStack pose;* X. o8 A3 [8 ?
- private final MultiBufferSource source;8 w# u1 {" E- S6 I. T
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
|* S4 b( g6 y1 f - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();' ~$ S2 w7 @1 a
3 p* }9 T6 [" d- }
& H Q/ V% I" r! O" u- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
! @: }3 W1 V+ B. i! t0 ? - if(x1 == x2 && y1 == y2 && z1 == z2){
r! d8 S* ^' ^8 f9 Z' D: u - return;. V4 S) J; v) v, E
- }
3 J' ]* f. u* P3 B! m: m - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){# z7 [1 b7 b1 y. v
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
8 M9 a/ v; E6 ]/ h9 \' K - }4 S- P4 L& `, I K* S
- pose.pushPose();
" T/ x% u( k2 r4 |0 r, q - final int newLight = convertLight(6);8 w# s7 }4 y ?. i, R8 r
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
7 T9 R( ^7 V) } - final float lineHeightSmall = (y2 - y1);! v! P+ e$ e4 U/ ]+ N, X
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);; l7 I! v; i' b- ]) G/ `" _
- pose.popPose();
1 d5 |7 ]+ t; w$ l" |% X% M - }* E8 G6 y0 Y5 r+ n3 e' g. _# V
- 7 u* t Z0 W1 f' O& _; L2 |
- private RenderType getLayers(String texture, int light) {
4 L, Q' [3 z4 C2 B5 J - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
. i- _2 p7 _6 @9 X5 s1 K - }
, K$ D6 C( m! W& X, I9 ]" @
* J( N+ i- _8 r% G! I5 {5 D0 V( n- private RenderType getLightTexture(ResourceLocation texture) {
/ |4 _3 N$ i8 Q% ?4 a: x - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
( o2 V0 n. \# f7 N+ P - }
/ J E9 ?0 i. H - ( z" y: }& P' _1 n ^. k
- private RenderType getTexture(ResourceLocation texture) {
. u! F; U# ]: i$ O$ B3 T - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
8 `( i; X! X; Y) C0 q$ p( | - }' G1 d, L [) w' t7 @7 M H5 g4 A
- 7 s1 t- z( k2 P) |5 k5 `* y
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {' o+ t! Y& ?/ U2 N
- if (cache.containsKey(identifier)) {
4 @, v3 x( w7 H* S- }2 ` - return cache.get(identifier);
, B9 \- N, f9 [0 t/ ~) C - } else {* p1 s4 Q# \3 a+ G+ N w" [
- final RenderType renderLayer = supplier.get();4 ]: |; t) e2 _# x' [9 P
- cache.put(identifier, renderLayer);$ N+ y. L; N( ^; Y# I$ L
- return renderLayer;
/ r$ s; G% z4 h7 _; P) g O - }6 P6 Y/ `0 i+ ?$ g3 @, a: D
- }
2 K y" D5 I" N, u4 p - }
复制代码 |
|