|
|
/ P" q0 ]0 ^* y9 |
行,这个怎么样
/ Q3 y. y, z. [3 k" z- package com.xhg78999.mtrfac.render;
) T; u6 T+ m$ m. B; Q3 W - $ `2 ]: }. y& }: V' L, o
- import com.mojang.blaze3d.vertex.PoseStack;
3 [6 D: v: h% I' ~/ _ - import com.mojang.blaze3d.vertex.VertexConsumer;
( Q( l+ b& I W - import net.minecraft.client.renderer.RenderType;
; v C8 \, t; a - import net.minecraft.resources.ResourceLocation;4 J* V" L0 K/ s
- ( l- f) M6 A. s, f+ w* V) G
- import java.util.*;7 a# w4 Y8 m* [& S2 Z/ M
- / ?5 O! O" \, L
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(8 ~: n* J+ e$ I# E1 o
- % Z9 I" M1 J7 V: \
- public class LineRender{
) i8 i' F" v' P: R% _, G - private final PoseStack pose; p5 ~& N9 }7 F8 n7 B3 N0 A
- private final MultiBufferSource source;
5 U1 I9 U# Y3 r* [ Z( T - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
8 J2 J, K' B) Q - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();) }8 W1 P& v" B$ `
- 1 q) w+ ~5 h, h. H* v
- 1 O V0 l. x# j- e+ r8 `: i' W# [
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){4 Y% G: }0 g; ~ [# e
- if(x1 == x2 && y1 == y2 && z1 == z2){
9 z& N9 L8 J) P- z l/ K0 m. l - return;/ S/ D9 x* n% o$ |0 e2 C
- }. F" g5 Q3 @% D' F* o! C
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){* D1 J7 `# k5 @% l
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
# b+ c: a o" m+ Q, A% t7 N - }( q% S: u8 z& |. M
- pose.pushPose();6 a' A! ^% S; z" }! R5 c. j L7 S
- final int newLight = convertLight(6);+ y& ]! s9 T! j7 C* h
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));& y& f. b2 M9 \0 K- T6 @' m; Y
- final float lineHeightSmall = (y2 - y1);2 C8 |# U; n0 ?! k
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);0 e9 k9 W! j: z% b* s) Q/ b) H: L0 g
- pose.popPose();0 e5 ]. a6 e1 A: i" G0 o
- }
3 _. t% y4 M; \+ t% }6 C# r+ T5 J - # _5 M4 U$ `6 B3 b
- private RenderType getLayers(String texture, int light) {( W3 h* E1 Q* I* U) P2 @
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
) W8 v# {/ y+ L. V5 _5 D - }+ S2 B# I5 ]6 I
- + T- O4 t0 ?2 a+ k3 o& u
- private RenderType getLightTexture(ResourceLocation texture) {
( N( q+ Y f% c* E% m7 L - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);, ]( {; V/ `) h* f
- }& z* X) u# ~3 o8 j; h4 Y7 g
) M/ E3 C- G( E2 D4 i- private RenderType getTexture(ResourceLocation texture) {
' l$ R1 T/ f' j, V - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
2 a% d( Q/ y; {; J - }. v( X$ n) A$ @' r1 B: j# F$ ?! k
- & U+ ` Q+ F7 I' n6 j
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
5 H* ]& Q" P) w6 f! U - if (cache.containsKey(identifier)) {
8 f/ k0 [. k, z5 O: d! U2 } d# D - return cache.get(identifier);
9 Q) e: Q2 o+ r" g% ^0 H - } else {
+ }# H3 m$ a! N( z! W5 v - final RenderType renderLayer = supplier.get();: Q+ V! F2 Z6 }) T5 t' Y6 `
- cache.put(identifier, renderLayer);- i- A6 M3 r, Q( X1 ?& k4 f0 S, v
- return renderLayer;
/ d, J X; G" ~ - }$ C" j. }4 f2 [
- }
- c- R3 ]$ z' t( Y - }
复制代码 |
|