|
|
( x' p) {5 r( ]1 s" q, B: q行,这个怎么样8 H- h( A5 [$ {2 P* d! a9 Z; v
- package com.xhg78999.mtrfac.render;7 Q, s6 u8 Q( z8 Y: A! H
j0 M# J6 f$ {0 }- import com.mojang.blaze3d.vertex.PoseStack;5 Y% \: K, t+ b
- import com.mojang.blaze3d.vertex.VertexConsumer;" u& `, q$ n( s1 ?
- import net.minecraft.client.renderer.RenderType;
% P* U6 T n: s) c1 M. t5 W - import net.minecraft.resources.ResourceLocation;. `5 X# O% x( W( z0 a
- 4 F! ~- y" B- Q) R9 V3 O
- import java.util.*;6 c' a0 q* _% A8 E: D( R. m
; A: o+ }9 r/ {- z) Y: i( K2 u- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
9 p. ^& I" D7 u: l
6 U$ m( T- }8 |) p6 Q4 L) ]8 O- public class LineRender{
3 G4 U# k5 t+ t - private final PoseStack pose;
]; k! k6 O9 a. D - private final MultiBufferSource source;
6 }- V3 d% d s/ y' C - private static final Map<String, RenderType> CACHE_A = new HashMap<>();. o. o( I, {, M6 m9 ?" a5 D
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();) V9 m* c1 ~# o0 X% M( s* Z2 D
- 2 I& h. ?/ k& L
2 u+ @+ ?7 k3 o8 P2 Y! I- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
" a! t8 }) h+ U3 ~ w) d - if(x1 == x2 && y1 == y2 && z1 == z2){ J; ]5 d+ l1 j# j
- return;9 ~" a4 x7 E* S+ K% _2 }5 s: u7 D* ?; f
- }5 r- X. ?3 b7 m; g+ P3 }6 L
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){* t) l# \5 c' W: x8 E
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
2 d1 V: A* \: B- e9 D - }
( J; |+ ~8 g0 C# e - pose.pushPose();! K% G7 R5 ~' f
- final int newLight = convertLight(6);
; O& T- T2 m; h - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
+ f: y4 z! m' s- y - final float lineHeightSmall = (y2 - y1);6 f7 C4 _% l Z( K' C* m: }2 w& y
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
! W7 x2 H I5 f$ Q, C5 w5 t - pose.popPose();/ j* _! O8 m( @8 k) q4 e& ?% M
- }( O* d* {# C( q& ]% k" _
- 7 P [/ r8 ]+ |- T2 ?" t" k
- private RenderType getLayers(String texture, int light) {
% y* S) K4 ~8 H+ s* {# u - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));; w9 @' I* A1 U1 c5 i9 H) u! z
- }
" r7 h% c# t0 ^; I1 G$ c& n
4 u# R% F# q w' ?+ c8 U- private RenderType getLightTexture(ResourceLocation texture) {5 _3 \# C2 }, r( B8 q
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
1 V0 P' j n6 W3 |) } - }/ a+ f3 M# \+ a$ o6 u- n ~/ j+ e4 t
! U7 k& ~4 L8 L/ l6 u% T$ g" B- private RenderType getTexture(ResourceLocation texture) {) ?6 p+ j$ h# f1 I/ [. V) d
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
9 n2 I( X! H' _, {2 J8 c - }/ G% s. h. }& N- ?/ z/ b
' M8 l" x) Y8 Z5 s5 z+ f+ k& B# l- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {3 R9 H0 g+ h. L; c
- if (cache.containsKey(identifier)) {
2 Q1 ]! t" I `/ L5 s, L! T - return cache.get(identifier);, n8 K! E$ k+ P( h2 E* \
- } else {* ?' A: }) ~% y0 ^* K! m4 w0 @: d% d
- final RenderType renderLayer = supplier.get();2 L2 d4 b& f: Z5 V1 K
- cache.put(identifier, renderLayer);+ o- T- P# b. \! X) C1 Y
- return renderLayer;+ \# o. A& X4 D9 t3 u8 Y2 m% ]
- }
5 a' Z' \9 v) U7 R9 j - }
0 d% I ~' ?6 d" v" g - }
复制代码 |
|