|
|
8 Y9 v9 i& t) H" y6 _行,这个怎么样
# R& x: U7 ]5 j' a# x+ Q- package com.xhg78999.mtrfac.render;1 E" K3 ?* D4 z) M) p7 m8 M. ?
0 y3 h- k# i2 z, k* D4 d- import com.mojang.blaze3d.vertex.PoseStack;) U. C! h4 y2 ^8 f) ]# L5 {# L* b: L: U; C
- import com.mojang.blaze3d.vertex.VertexConsumer;2 U2 A. A1 R: ^4 C6 h' M
- import net.minecraft.client.renderer.RenderType;
8 w/ b% _7 K& a3 D - import net.minecraft.resources.ResourceLocation;! i! ]3 l6 o; i g9 d
6 b! `8 w! k- ^$ ^" q8 Z- import java.util.*;( |4 n: o6 A8 w' n2 k3 s8 ]8 V
- 9 b& y0 J* I" f( w& f
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
+ m4 N4 Z5 i6 m! H! Q - 2 J: a3 [- n3 i T9 J/ E- ]& H& u
- public class LineRender{8 u. S- L ]& A/ s- Z) y% B
- private final PoseStack pose;
6 |1 Y7 P- [+ U, c, @4 e - private final MultiBufferSource source;
2 }$ G5 R! i& r1 B - private static final Map<String, RenderType> CACHE_A = new HashMap<>();: O' U! G( k( v) D6 O/ i+ ?3 `
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
: @% V1 a. `; t* A k Q2 I5 K
]# T) T. { [: G2 A( u( W' f* A" t. y- 4 S, B% }1 n5 l/ v4 H
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
2 l7 T0 j% T) V! P) C - if(x1 == x2 && y1 == y2 && z1 == z2){
) y: K _6 F! d' h0 K - return;
; F, \4 o$ b' ?; X2 {* ~% f, u8 v - }! L+ W: L2 b: E2 z
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
/ F5 }; \+ L) g. S' V8 a5 [ - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
+ w+ `% G {/ r4 ?0 [8 ~* S - }, {5 I: ]9 V+ S/ {: g
- pose.pushPose();4 @8 G8 ~( ^9 y( B
- final int newLight = convertLight(6);* M7 ]2 t9 Y/ i6 ~' `! E; }' G/ e
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
3 e) ^6 M" v; X% H, H) a - final float lineHeightSmall = (y2 - y1);: C- H( f5 a& A/ V
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);+ {# c7 _* L x/ P* @) Z
- pose.popPose();
. X8 S" ]: `' ] {* v8 Y( |0 n! t7 ~ - }
3 d. P; C! {: {& l* t) b8 @ ?
2 T1 b5 n) L' P+ C6 X- private RenderType getLayers(String texture, int light) {
0 }! S, I" i6 d- h2 S6 `4 ` - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));) {% Q. n) A' a6 T
- }
2 \' }3 D/ R( y
( K7 g4 H$ ]$ W! g$ T0 ?' V/ W y- private RenderType getLightTexture(ResourceLocation texture) {' z# l8 q. M2 R( q, ], a' `
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
! N: J ^5 x: d# |+ B - } n0 q' ]/ X1 r, P3 h. i9 r
- ! r {2 L* ^* S. F
- private RenderType getTexture(ResourceLocation texture) {, _0 b& o; N7 Z# f3 e- y) u# _0 }
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
# Y+ {0 j( G! Z1 l4 T8 w6 G6 h - }
+ O0 b; g6 }: S* M! H1 X5 `. g - & ^! O; R. D" @/ G% g
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {* u2 j7 d% b2 G& Y5 s8 I9 k* z
- if (cache.containsKey(identifier)) {. L) m" Y, i9 A n
- return cache.get(identifier);
* {, `8 X: D6 a0 m7 z1 G }" n! G" K - } else {0 Z! b2 l z& g4 d5 J
- final RenderType renderLayer = supplier.get();
6 b+ V+ r% C9 n: o( M8 ? - cache.put(identifier, renderLayer);0 V2 Y" v, F3 u
- return renderLayer;
" @/ Y+ o8 n" ?4 G- T - }
: P, c0 j2 t, y8 w: u! u - }
& B$ z2 q7 P+ i/ L$ }1 H - }
复制代码 |
|