|
|
( }$ \6 l. f1 m$ X2 ~5 _9 f行,这个怎么样/ C6 B1 ~' h( z& H Z( O
- package com.xhg78999.mtrfac.render;0 H: Q0 I( C# P3 K5 Q
: Z$ ?6 R, n( \ e' A4 E' i- import com.mojang.blaze3d.vertex.PoseStack;
+ o. q. G6 q M! h- m3 m; A3 `8 |! g - import com.mojang.blaze3d.vertex.VertexConsumer;
- ~0 g4 ~' O; V z- D) } - import net.minecraft.client.renderer.RenderType;7 _6 y h( d4 X9 [% G
- import net.minecraft.resources.ResourceLocation;( s2 V( \% y0 ^# N+ V) b; e
- ) R# P% ^, B7 G+ g5 ~! X
- import java.util.*;- `" w" c/ d# F/ x) R' f* X
- o7 T4 I& s* _* |" K- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
) `6 T; a2 f- K6 _9 P! G - 1 l/ H$ ?- Y- V$ Y3 o! p
- public class LineRender{ N7 S, A1 Z1 X* i; {) F
- private final PoseStack pose;
4 B: j9 S9 q' e$ l* t- K: w - private final MultiBufferSource source;% W& k. S2 T& u/ f& w5 r* x
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
( ^. V, i8 x% s3 y& d6 A - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();" m; P) }* T1 k0 |* S
4 u2 o# O- y5 G' @, F* I- " J+ F, r- Q( i: h+ v6 {6 e# k
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){% @9 V+ u) E% ?
- if(x1 == x2 && y1 == y2 && z1 == z2){
x: ]* g+ h1 S9 B - return;: r4 q4 f- q. R4 B( W" q
- }
( [. e: v) q( j. M) y - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
$ ], z7 m( {& r" Z8 y - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");) ~. i+ }+ l! C8 t
- }
: q; O4 n1 e$ r2 B. g- P4 |: X - pose.pushPose();3 U9 Y/ x$ P% }8 Q7 c$ |
- final int newLight = convertLight(6);& \8 I$ E0 w# K: s; g
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));# E% p; P6 \* p8 k
- final float lineHeightSmall = (y2 - y1);
* D9 l9 l$ }, m3 K( | - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
- p8 C7 _. d: k - pose.popPose(); S( f% R: V5 U& V; _7 o
- }/ Z. f/ j* F+ F! I4 p; Z! q
$ s1 G# V; V+ W# a- private RenderType getLayers(String texture, int light) {5 c9 ^! n$ ~# J
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture)); D! x' L/ S" N! ]4 I
- }
4 f4 M4 Z' }6 [, }2 @
! z4 G8 t% k8 T* R! K; x- private RenderType getLightTexture(ResourceLocation texture) {
" m: j6 i" I, |# ?; ~6 O, N - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
* J' p/ ~0 c# P* M9 J - }5 s6 l3 K. J6 E
% x( a* J8 }' j" J& _! T! k- private RenderType getTexture(ResourceLocation texture) {; Y, i0 n$ h& A! |: }, n# i
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
# x' d! G8 N; E/ p8 H - }
- D9 C6 g% ~ M% r/ T2 F
+ {. L& X9 V( `) U9 k, }( _- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {" o, M) o, w" L' ?1 e
- if (cache.containsKey(identifier)) {4 A" l- { N, `7 |
- return cache.get(identifier);
- R7 C9 M5 l! s2 g& \; | - } else {2 O* S; o/ L! `" a3 t
- final RenderType renderLayer = supplier.get();
/ E9 e' l) n6 G5 L4 P, t - cache.put(identifier, renderLayer);
- K# s6 N3 c- \. V5 W - return renderLayer;
% E" a, O; s( r/ g - }
! a8 c0 O! z( B3 J& O, G# o - }
. B9 B, Y F7 D+ G9 {7 b: Y0 l - }
复制代码 |
|