|
|
/ ^1 _1 i0 _" H" H% X行,这个怎么样+ R& x/ |) w3 \" O9 I6 j
- package com.xhg78999.mtrfac.render;7 _1 f$ m% x6 r2 R R
- " e$ @% b" ^+ e* B/ {. \& w9 G, d
- import com.mojang.blaze3d.vertex.PoseStack;6 J) f' S" ~/ c, E( q' C5 w: I6 ?
- import com.mojang.blaze3d.vertex.VertexConsumer;7 D- `3 T' Q; [* {" b- w
- import net.minecraft.client.renderer.RenderType;0 n, q) f5 n' Z/ w; }/ t6 K2 l
- import net.minecraft.resources.ResourceLocation;2 J5 u7 J: H* I/ M W
4 ^* n# \* I- e/ K% v1 o- import java.util.*;
. }3 _" A& ], E
3 ^2 n; K* P+ g8 j9 G/ P5 w- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
! s. ?3 w- K1 Q9 @; G5 H. \! E9 q" n
) [0 K8 s3 ]/ f9 O- public class LineRender{
2 u: `; g9 K: w/ u2 A* G% D - private final PoseStack pose;
/ N2 `; b4 ~0 @" N( I3 s - private final MultiBufferSource source;' {( u$ E! U6 L+ q
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();- g ?8 s3 G3 ^* L# n( V' ]! z3 g
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
0 e7 ^2 F$ w3 h8 l: f1 o. [
3 E% g+ ]8 t) m6 o
/ \' J2 A3 J B' H* }. i9 v- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){( h* z1 ?7 c+ _# d' h$ r+ l4 W2 V1 g
- if(x1 == x2 && y1 == y2 && z1 == z2){& b1 @0 f. N$ G; e" v& i5 U
- return;
- G2 h$ g: b- Y- A" L( j8 b6 A7 ^$ m - }
3 Z0 A/ i3 j+ P6 o7 p5 w - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){" q; A( ]: `' E. n, {
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");! g# X# {! n& z% V$ B8 j4 f
- }
" s q- t$ j# {3 d - pose.pushPose();
( @7 i& F! g2 q0 Q" ~$ B0 N# c - final int newLight = convertLight(6);/ [) C) Z6 n9 X0 x
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false)); `. n8 y& |) g) F7 y3 g# @% M
- final float lineHeightSmall = (y2 - y1);
+ H4 t" B. [4 Z) I9 R6 r - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
1 V! G( p; }0 y) U - pose.popPose();0 q4 r" y7 Y8 S) U, |' e0 H8 l
- }7 j0 b/ j4 w& J. }1 o% z
- ( v( V, D" @: W. A: X. A# J9 y
- private RenderType getLayers(String texture, int light) {
U( R4 P, l+ B) W w( G9 h - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
( p, l! B3 d* e# c; M# h - }
- D4 F4 ~ [' B
4 j9 n q b' x- |7 T- private RenderType getLightTexture(ResourceLocation texture) {
# J( L2 j( g3 o1 V - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);3 {8 ?" Y4 H* ]4 W# e
- }7 s e, F; U: |" r
- 6 r/ q& M6 T( s* A- I. y+ X
- private RenderType getTexture(ResourceLocation texture) {4 X3 l5 C6 ^% L3 {0 `4 x5 }
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
7 X, w" z v2 [- W - }
- {! p' { d# d1 j4 U
. }( _+ T8 l8 j) h/ A- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {5 h& O4 f* x9 ~! Y+ z4 U- b- Y
- if (cache.containsKey(identifier)) {% N( K7 `7 ^5 o/ |4 y
- return cache.get(identifier);* L8 o2 [ v& g' E- f6 K
- } else {. _0 P7 m& w& N+ L# C$ f
- final RenderType renderLayer = supplier.get();% o x5 f7 |. |7 M* o
- cache.put(identifier, renderLayer);7 U7 z0 ]' h! |0 Y
- return renderLayer;7 e' W5 I2 u$ T6 }7 G$ u
- }
6 R8 L6 ~1 e# } u6 y i6 v1 O - }! N1 c+ Y# \2 w3 P9 u* v! b: \4 ^+ O
- }
复制代码 |
|