|
|
9 a2 O v& q# s5 n
行,这个怎么样
4 M0 x" Y* O7 j# a- package com.xhg78999.mtrfac.render;/ U* \! ]" W- V. G
$ d& g2 G, b- o: s3 d! X/ `- import com.mojang.blaze3d.vertex.PoseStack;( l8 \7 R* E. u% d5 g \& z
- import com.mojang.blaze3d.vertex.VertexConsumer;0 H7 A; l3 T: i2 ]- v* A
- import net.minecraft.client.renderer.RenderType;# K$ e- D- j& F9 G' j. a+ {
- import net.minecraft.resources.ResourceLocation;$ j- }' R! b3 w( K# }; @1 y
- & P2 ?( A1 K5 x) _* ?
- import java.util.*;
. \0 q+ X6 I8 }7 `2 M - ' @' x4 W/ H# E& g
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
- w) j$ ], w9 f( Z
) ^/ R/ t) q) v$ b- public class LineRender{1 ]" B& J8 c6 M) u8 ~
- private final PoseStack pose;
; `# A5 Z* Z0 Y3 c/ U5 `+ ?+ } - private final MultiBufferSource source;
- t+ E0 n( z1 |+ o# H2 N2 I | - private static final Map<String, RenderType> CACHE_A = new HashMap<>();4 N. V1 U# k- w% s f* b
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();9 p% D5 \; A7 ]; i4 @
+ k* S; X" ^1 k/ p! Q; |( X
% H+ i1 S5 V$ O3 v: M/ ~1 ]- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){, ?2 ~8 g1 F3 U* p1 ?
- if(x1 == x2 && y1 == y2 && z1 == z2){, `% I @5 L* F
- return;( ^* H n, k" o- m9 H6 P9 J9 ~2 q
- }( \9 Q+ Z% y: w; G- M% a8 S
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){6 ^; U# q- h3 }( P
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
r* u/ S; Q% j4 D5 c- Z O" v6 a - }, y5 {' t) {4 R' f
- pose.pushPose();
: [, e1 X, u! V. F9 k4 I) n" p - final int newLight = convertLight(6);
7 M: M- Z0 F+ ?" c K. U# I - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));7 b. W* _4 X' k" f4 o5 v. p
- final float lineHeightSmall = (y2 - y1);1 J) L( d8 J" L7 d4 R/ B- [. P
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
* J1 @6 V4 F# [$ w) s, C - pose.popPose();
1 m$ C! ?+ u) q1 ^( a1 h- _ - }3 b9 L7 l8 T4 V! X, M
9 u* u% N% v2 o- private RenderType getLayers(String texture, int light) {
7 q/ u, M) j. f+ Y# ` - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));! ]& D4 r6 @4 ]# p! Q7 M& Q
- }* f$ Q! Y; g' z% K9 S
- 1 K/ w4 J' _' c( G. l
- private RenderType getLightTexture(ResourceLocation texture) {( w, E* f8 v B
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
5 r1 s2 M9 T; V8 y* r% a - }: G& ^/ c+ \7 b4 Z- {) O1 q
4 [ q5 M; s9 E/ T! r4 R8 W0 F- private RenderType getTexture(ResourceLocation texture) {7 h. P! E% v) g. G% o. p! @' ~" e
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);4 F3 X2 f! X2 n" A. F% ]
- }
( x* N8 r# O7 R0 P - 9 C" f6 T' M. K) X0 m3 H) {7 Y
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {% U: k( L0 w' X& ~5 E# @
- if (cache.containsKey(identifier)) {
8 }# U+ D( Q% p5 t; p* I0 X - return cache.get(identifier);+ V1 z6 ^, X, i4 S' t
- } else {* r$ r8 E- h/ O7 d+ R" Y! o6 y
- final RenderType renderLayer = supplier.get();
: I N! a2 g ^7 q. \, L - cache.put(identifier, renderLayer);
( U8 g/ \# [" ?8 _1 t+ d* q - return renderLayer;- R3 a4 v8 ~+ z: s3 K
- }
( }% F! ^( {9 x% o' d; d- y8 k - }) Y- {0 }* I! b; r$ R1 W
- }
复制代码 |
|