|
|
4 _7 c9 | t9 E& y5 S
行,这个怎么样2 ?: m* V) w/ o5 M4 B
- package com.xhg78999.mtrfac.render;# e" y/ b8 ]! l2 P
- 8 {/ v/ u, |, D/ I
- import com.mojang.blaze3d.vertex.PoseStack;
6 v( l3 T3 j) S* p7 l/ Z - import com.mojang.blaze3d.vertex.VertexConsumer;! k! L5 ?8 L0 b/ C
- import net.minecraft.client.renderer.RenderType;7 y2 Y) O6 n* k' S$ q
- import net.minecraft.resources.ResourceLocation;
+ X2 ]& n2 u; l) c+ ]( X/ F `
8 S& O6 o: S4 ` U8 N- u2 R& b. h- `8 t- import java.util.*;' d0 Z7 b* J! l2 r4 s5 a
- 0 d9 v8 ^0 r! z6 j' A
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(3 R# m: n6 v/ i; F( ]
- ! X8 E" c" }+ x2 O! ^! z
- public class LineRender{
1 Z; B0 J9 V0 r- M# X3 v - private final PoseStack pose;
7 u7 s% i, K! U* H7 M' F) l0 a- ~ - private final MultiBufferSource source;
7 v% P/ P7 G$ {- U# y9 q# p - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
1 x% ?1 [2 j9 R# m3 |& w X - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
; ]( t% F, d/ C# n - / W4 _1 a/ T% u9 l1 q" T
: `/ ?6 ~/ i; g) @- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
: q5 A) G2 F, Q. S) e8 \ - if(x1 == x2 && y1 == y2 && z1 == z2){/ t0 d( C. U: S# K. ?4 U
- return;
, @; a6 o+ ?' N& [! ? - }7 N" h8 H. A1 m1 h+ S
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){/ k( @4 a, ]# f( } ~" g: ~
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");, |7 w8 i4 a* S) E/ u0 m z, i
- }
+ c/ a" {+ o% w$ k2 S1 g - pose.pushPose();
1 |( X2 Q7 u0 N, t# F' ?8 l - final int newLight = convertLight(6);
V" o, p4 \" Y9 m! J2 Y6 G - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));. }) P9 }8 N" E3 a/ g
- final float lineHeightSmall = (y2 - y1);
) y% \: Q; P f4 c - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);; _1 Z) T. X/ W( c
- pose.popPose();
. E! b! Q7 W! T, T$ F: w - }, f& t, L/ T# _
- . T& f w" d4 a; D. v# J4 {2 \
- private RenderType getLayers(String texture, int light) {
% e8 u% a9 s/ o$ b - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
, I6 l% X( a; Q5 x - }$ Q' a; E7 v/ j" G2 t
3 |/ P; w/ C* G! b7 \& Z9 m" Q+ P$ m- private RenderType getLightTexture(ResourceLocation texture) {
: e! z( N$ ]7 d8 W - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
# ~% R% Y. |2 n l( F& b) [- a - }
: T. D% f: ~8 D! z
2 x% `' `2 U. r) h" u- P- private RenderType getTexture(ResourceLocation texture) {
0 L+ B, s/ m. y - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
$ ^8 }9 W% \: z% s3 W! \ - }
/ k5 Z8 Z b% |+ h8 L+ H. n8 ^ - # @- C0 @" ^# \6 K
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
" A9 o. [; M2 j& Z7 B - if (cache.containsKey(identifier)) {
- D }, J& V8 U( P' j8 j: V - return cache.get(identifier);4 b3 `! s' y) P
- } else {; i% Y w, M5 q" D4 d* x# o9 b
- final RenderType renderLayer = supplier.get();
0 |& Q) z; K ~2 H - cache.put(identifier, renderLayer);3 v" F Q |+ I$ O( w/ i
- return renderLayer;
7 X" R' ]# v9 W - }! W& W2 J" h6 @; g$ ]1 N; l% m- ~% K
- }
! u, K0 J$ z$ D2 Q A4 t - }
复制代码 |
|