|
|
: _& \9 z# C3 _; b, ~
行,这个怎么样
, U- t0 ^& V" Q& R* J' ^- package com.xhg78999.mtrfac.render;9 }, o4 k" l- ]" r5 E& U! S
- 4 r+ _. F, @0 ^
- import com.mojang.blaze3d.vertex.PoseStack;
. E: C9 E* z2 w5 W) D( s/ n - import com.mojang.blaze3d.vertex.VertexConsumer;
1 R6 V# Z" H/ N- c3 L" @" u) f - import net.minecraft.client.renderer.RenderType;
' M6 e& w& ]8 P6 J. q! \1 S& n - import net.minecraft.resources.ResourceLocation;
" G, H- z! ^4 K+ [ - ' _8 k. a3 k2 D2 L8 ?4 K
- import java.util.*;
% ^5 ^$ f# V- E% c5 x - . ?+ \( }; G, |% ~. q& J; ]6 ]
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(" f6 c+ V- m0 x" \7 x' ~( R+ Y1 Y
- ) w0 M0 O$ _' ^% j
- public class LineRender{6 x! N+ }5 r* h3 ?, w x: i6 c
- private final PoseStack pose;
! J, i0 A0 Y: ~, K7 V - private final MultiBufferSource source;
6 X7 G2 L. t e' Y/ B) g3 u - private static final Map<String, RenderType> CACHE_A = new HashMap<>();1 A2 i- f0 {3 J" @' p+ Q& N
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
4 [) K/ g& u, N3 z1 }. g2 z - ' D! |4 u) o! C# {8 F
; V4 M4 k! `& X. g4 Q- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
2 t" A4 J# E) ` - if(x1 == x2 && y1 == y2 && z1 == z2){
; a2 z8 g/ d2 @& Y5 h3 d9 \7 R - return;
# b5 a' a1 f8 p; q - }9 X5 O& A& y# ^
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){1 m& k) u* H& v5 p R
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");* i) x0 N2 v" [8 x* U |
- }4 U% N D/ R, A% O% J" d! U
- pose.pushPose();
4 y. N& ]7 `# M' V - final int newLight = convertLight(6);
, G8 W) V1 W- @' J5 [; i. c - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
* \( B4 H4 e: L+ y7 x4 L - final float lineHeightSmall = (y2 - y1);, L3 W/ i7 z; \/ U7 L. R
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
# m% [3 n$ [+ w/ E1 F - pose.popPose();
4 V1 s. A* _' d6 V5 f2 a - }
3 v8 u5 c! D* i
& F" i2 B! j5 T$ l' T( m- private RenderType getLayers(String texture, int light) {
1 r9 O; R+ M# F, a- j$ g - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));; h5 S: Q7 J: D ~
- }
% ], c" X$ K/ b0 \# D1 Q' Y - + M5 \) R; w& p* G7 W& Q# c
- private RenderType getLightTexture(ResourceLocation texture) {' Y* M; D# @* t8 `% W/ j
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
o4 N& E% s; q, t+ r! m - }5 ~3 J( ]: x; [; H" F8 O1 X
- / T5 f) R( y' M2 e# C
- private RenderType getTexture(ResourceLocation texture) {/ l% R. Z+ u9 d+ k
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
+ |* l" [: c2 N m/ d& R - }: X$ I# n( V: U0 J$ [! g7 v
- * j5 b/ `( t0 i. p( n0 k
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
! y {( j8 w. m& Q* m2 o1 _ - if (cache.containsKey(identifier)) {& ?' P+ n; \6 I' ?' ^0 E9 y
- return cache.get(identifier);; I3 f0 B- j. v1 r: ]# S
- } else {! a, n5 X! p a" ^/ t
- final RenderType renderLayer = supplier.get();
. e) I* o( W8 q2 ~" Z+ T) C( e: m - cache.put(identifier, renderLayer);
; M! r; n, H: }( d {* |; | - return renderLayer;/ j5 M' |$ ]5 k8 I" g
- }
/ g K! T7 d/ e+ r2 l. b - }
0 f0 }& r1 o/ H, b - }
复制代码 |
|