|
|
! w2 g3 Y C% G( A) Z4 E1 d: K3 q行,这个怎么样
* |" d4 O" G! ^4 X+ N- package com.xhg78999.mtrfac.render;
0 B! w* H( [. p) P( c0 J, `/ q1 j2 j - / y' F9 d3 K( J4 R% c% G
- import com.mojang.blaze3d.vertex.PoseStack;4 Q; \6 l* W' W4 ]
- import com.mojang.blaze3d.vertex.VertexConsumer;
+ h6 P' X" H* I, C4 V5 ~: A - import net.minecraft.client.renderer.RenderType;
; q; w0 v$ s) ?: R2 o$ @4 {9 V - import net.minecraft.resources.ResourceLocation;# @) Q3 ?+ B. _* D7 h2 B8 e( n$ @
2 U3 S9 U' q: S- m e j- import java.util.*;
+ c* j! A* L( d0 u
5 {7 }) i) B, A8 g! m* j- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(( t2 o+ e; o& W* Z
- a: W! v& |( c `) x# O
- public class LineRender{
8 C- p7 M& C* }2 H: S* o' x& T' V - private final PoseStack pose; d+ [% @$ ]+ l) E5 {& U
- private final MultiBufferSource source;" L5 D6 }! f' O. ?+ }, t9 v
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();( ~: f4 w$ I9 l
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();5 g" {- U2 k* N) a
5 g J: w% T; Z( e6 \8 I- 5 Z+ l8 t# ~% \9 {- o. o2 i: s' T
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
- {/ m% M3 L @8 B# z" O% J - if(x1 == x2 && y1 == y2 && z1 == z2){# L7 ?$ [$ b& H* t, }; [
- return;
2 z2 J9 Z" l1 }% s - }
6 ]" G. `, D5 ~2 O9 d - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){) {6 c5 T9 p6 z9 F! V# h
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
' e, Q9 G" B8 A- Q6 ` - }
# t: t. r. b# A6 Y/ H - pose.pushPose();
2 g2 n$ D5 l5 `1 l% i# m: t - final int newLight = convertLight(6);
W, X. S3 `- ^2 z' Y9 a t - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));, t4 a9 Y& R* o7 |) Z
- final float lineHeightSmall = (y2 - y1);) ]4 d) i; X" K8 M& O) \. r& _
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
/ i" p: m0 |% j3 i8 X/ l - pose.popPose();6 v9 i6 @: j1 M
- }
: N) P8 n1 r X6 q! H2 g - 4 P+ d' d3 b' }" u# ~' d
- private RenderType getLayers(String texture, int light) {' X% d. _' {. {. Y/ S8 y- K
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
. A5 G6 N! E: T - }
2 E; I8 w/ C1 a/ u+ f4 N& s9 K
) {: [7 V' U/ |2 b: ]- private RenderType getLightTexture(ResourceLocation texture) {. ~: C5 x; I1 Q
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
& }& v. j) \" I% w. e K* J5 j - }
* o: y# Z! e- m8 H$ |0 M0 F
' \ L& U0 E J- private RenderType getTexture(ResourceLocation texture) {) Q m3 Y, G/ R0 q( U$ e' U6 ]
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
6 a4 b3 j8 _1 U% |: S - }
; g |3 Q, M2 v! l! L. Y - 5 O" a& D5 I9 r; W: F# z8 a
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
* v$ a/ ~9 Q, D/ [3 e: X7 C* r - if (cache.containsKey(identifier)) {
. N* s" y9 e) @" ? - return cache.get(identifier);+ }/ a2 {- b9 E; f, l
- } else {
: } j B5 v C, A6 T1 ] - final RenderType renderLayer = supplier.get();
, B8 w% l+ p# W; \6 l( a - cache.put(identifier, renderLayer);) \2 N( l: p- }. q9 g/ v: }% z0 N
- return renderLayer;
% @4 a* i+ \' a# p - }
+ N& r/ C1 H9 c* }6 D7 g - }
0 h c9 d( `* x6 v. N0 P% q - }
复制代码 |
|