|
|
& n; {) k% i" a; n
行,这个怎么样
% t& B- v/ P& K) l& R- package com.xhg78999.mtrfac.render; ]8 L' c0 }( \
) Q+ E: B) S1 V' ?" C% }- import com.mojang.blaze3d.vertex.PoseStack;
) y' Q; E, v1 B( U8 L3 c% q - import com.mojang.blaze3d.vertex.VertexConsumer;) i0 b5 y7 _+ S4 T. l5 ]
- import net.minecraft.client.renderer.RenderType;
2 `6 c: k6 J3 d5 o6 O1 b - import net.minecraft.resources.ResourceLocation;
: ]- u. R" Y2 G1 T; _; b u+ @ - & ?& }: j/ t5 r4 G$ n( V5 \# n$ ~) G
- import java.util.*;
+ Q( H7 r1 E* h( o% P4 o7 I
- C: C9 L1 c) U8 ]: M: k- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
S4 M$ n1 U+ B5 `
& f' |) n0 B, t6 \- public class LineRender{ D4 J# T2 s4 }- v5 b8 {& Q& E
- private final PoseStack pose;
" Q. I7 q/ m, D; ] |( t - private final MultiBufferSource source; k% x. F$ L- O, K, R2 O- L
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
) T( z, c- [0 t# c1 a - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
" _+ B: ` |" d2 z - 9 T L6 w% J4 Y4 L& `8 V% n8 q6 E7 w8 Q
3 ], @9 k& d% c: p& _- Z, v- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){! X' ^& _( P2 i/ t, N
- if(x1 == x2 && y1 == y2 && z1 == z2){
3 X$ p, e& A( [2 o, c4 D- }& \% ~ - return;6 E( t* _ o' H8 z% o7 }
- }& t" j5 H2 `: ^& ?
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){/ n. w: `, n0 U# t6 A
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");# x$ \& O8 v% B" }3 f' ~, z
- }
+ @/ {: Q* S3 U' E - pose.pushPose();
: n7 Y# a4 ~* R, s. ] - final int newLight = convertLight(6);
' v6 k: j; a4 s6 [( M" P- K x9 | - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
) {+ w& [( ^% W - final float lineHeightSmall = (y2 - y1);! @3 O9 S+ Y- D' S/ u$ @
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
7 Q7 O+ t4 \+ s) S5 |$ L3 Q5 O - pose.popPose();
3 j/ G! R5 S' {! a8 r5 ^ - }
3 ?9 [5 F) l: z
4 V$ S, ~" L0 e+ K- private RenderType getLayers(String texture, int light) {
: M9 Y8 a" H6 Z. Z6 S: N% _% ] - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));; g) z0 D" e8 g
- }
3 t7 v& ^7 F+ m ? - " ` c+ B* z" @
- private RenderType getLightTexture(ResourceLocation texture) {* D% C% G: v; [ S* t# y- c, Y* u
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);, `; F' G( D- B: _
- }+ R1 b3 l0 D' S6 M9 ]$ ~
- : o# u1 M5 p; q9 q( \, f8 [* F
- private RenderType getTexture(ResourceLocation texture) {
2 R- ~' W( o3 G, F; o+ O - return this.cache(texture, () -> entityCutout(texture), CACHE_B);, U5 w3 w) n* S( L3 t4 n
- }
5 X' J" V) o: D' n5 }# d2 k# [
% B( O4 I* c7 B h- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {$ a! L9 X; ?8 n, w" A' W/ c
- if (cache.containsKey(identifier)) {
) I! d, b0 K- c* q* G - return cache.get(identifier);) a* T% [: M- k- t
- } else {
4 l' r) J/ R3 i - final RenderType renderLayer = supplier.get();# F& z; j1 A" @( |
- cache.put(identifier, renderLayer);
! o- k' a8 C. y- ^ - return renderLayer;7 O7 x! y% D' T! I7 b
- }
" V9 o( p/ f( W$ F8 u6 v- g - }% x" A8 ~. {; {: M, G
- }
复制代码 |
|