|
|
( J8 o1 \ k, c" F' K. _5 n/ u7 k
行,这个怎么样- Y$ u- X" f" ~1 w) Y6 o) T6 V ~
- package com.xhg78999.mtrfac.render;* d) x: X! ~, u, Z
) _6 b$ T! U3 O% p! g" P- import com.mojang.blaze3d.vertex.PoseStack;
T. t0 L. r/ k2 Y" V - import com.mojang.blaze3d.vertex.VertexConsumer;
+ B' u" w# {' q$ V) f - import net.minecraft.client.renderer.RenderType;) y; X, z6 Q" A( m) M! P3 c
- import net.minecraft.resources.ResourceLocation;2 O& s) U, ?* B1 n. ~8 K
, q1 X1 z/ v$ c* n, Y! V- import java.util.*;7 [+ a5 p7 f# w! K6 b# i+ h. g# D/ G
' U: o: ~6 O3 |& i# ]& `- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
w8 x" }, F& `, \% Y/ t - 6 M* H9 [! ^% n9 `* t
- public class LineRender{0 w6 @, \: L- Q9 u
- private final PoseStack pose;: B- w- }4 L# C7 j# g8 ?
- private final MultiBufferSource source;5 f# c! T4 p* n: z2 a
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
0 x4 R" Q- U9 n9 C9 ^. h - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
/ G# m3 W. r7 ^* q/ p5 h( n/ h% V - ) l1 A# \# s L7 w0 e0 }
- 2 Y9 K4 p `( F
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
& [: }% k9 X- C% o - if(x1 == x2 && y1 == y2 && z1 == z2){( j* g3 U# y& y( E+ _7 V5 m
- return;
' b0 `3 ~1 `& U9 k - }8 V8 W( w3 I6 Q
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
7 G7 K$ k* G& V0 M4 x - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
4 c6 F r+ N% r- y6 w - }
- x E; M0 x w- x - pose.pushPose();
1 }6 ~* p/ i4 x0 n% l - final int newLight = convertLight(6);1 ]8 ~: p- X. _! `' V$ U
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));$ \1 N+ x# W- G( n
- final float lineHeightSmall = (y2 - y1);
. [, M4 M" ^" \( ~* }# g - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
. O `& x6 E9 d y& n- ]5 Q2 ~& J - pose.popPose();
! ?- a7 P" _2 W) Z3 b - }
0 @" x+ W7 N1 ~2 \0 X' @7 | - 8 ] o; {7 Q8 B0 `% L( `5 z
- private RenderType getLayers(String texture, int light) {( N5 k2 L6 E6 I
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
4 k* E6 N0 L2 ~ - }5 E2 V% F; Q5 I7 h+ l* Y
; o- E0 q1 I P# l3 i- private RenderType getLightTexture(ResourceLocation texture) {9 q' T l: s* `* l) h" C+ q. a
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);2 O1 {" [( v. t# Y! h3 f5 ]2 ?0 _
- }, y" g; ~. c" B
- 3 T9 d O+ s* y# C8 c8 a& z+ k/ t
- private RenderType getTexture(ResourceLocation texture) {
5 D( G( I( t9 I5 S4 |& ~ - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
6 U: i' Z, a r8 d2 {3 ~ - }
9 Y# r2 u1 p0 K' Q% D - % |- M) D3 _5 |- r
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {0 v* ]9 c( U- n! b t j9 J( u- w
- if (cache.containsKey(identifier)) {7 W# M1 e& q' F; Q& Y3 a
- return cache.get(identifier);- W* @7 ?+ \/ p# D- l0 I2 K' Z
- } else {; y" h+ }4 C) V$ l- r$ k v# |0 h9 ?
- final RenderType renderLayer = supplier.get();( o. _7 X5 U5 H6 w/ b6 n8 X9 S/ R
- cache.put(identifier, renderLayer);8 Z5 j6 }3 P* P. Z
- return renderLayer;
* F8 U! s S) ?- ]2 L - }5 b: i$ {* G U" e. o' D/ t0 G
- }) A/ z' E7 d; p9 d7 k; Z) ~
- }
复制代码 |
|