|
|
' F5 _( u, e. D2 z" \9 T& {行,这个怎么样
" j% \+ V5 X3 W- package com.xhg78999.mtrfac.render;
# M1 ?4 H) d7 C/ T
* ?+ Z$ d+ p l0 i3 A0 \- import com.mojang.blaze3d.vertex.PoseStack; `- }0 Y" x4 }) h! A8 n( H8 H
- import com.mojang.blaze3d.vertex.VertexConsumer;- w. ]9 s1 W9 N9 i
- import net.minecraft.client.renderer.RenderType;+ g4 ]6 }3 m3 ]
- import net.minecraft.resources.ResourceLocation;: H( C/ ]% n! M5 K/ k( b
* u" n* E# @' o7 K+ K- import java.util.*;8 @, n( y# k( I% t! U
- G# f! |+ P/ _: D5 I- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
- y0 X. C; T3 {* A5 l2 U - ! e( u0 N) h( s1 ^; L h
- public class LineRender{( _% F3 j$ z' s
- private final PoseStack pose;2 A' M6 `4 _ M; x0 g, H0 f
- private final MultiBufferSource source;
6 u9 P" X1 x1 r2 s' u: V - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
) d% O* c, w1 {5 D" y( ^ - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
( ?( c$ v. ~" T( `; u, i$ U
( R' |4 E3 l! l0 Q4 c1 w- 0 s+ L- n. O% k0 @- Q
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
+ H! L1 u, A" H - if(x1 == x2 && y1 == y2 && z1 == z2){
; P4 n; p0 L, o: b - return;9 N: L g- J) I% a& Y. O: q
- }5 K* H( v# r! ]; V5 ]2 q$ R' \
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
; I ^- f, M% g; A - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)"); \% _* J+ O$ E' j
- }
: d4 w; z+ u+ b' ? - pose.pushPose();
* D+ k0 f4 Y4 w, o ~+ P, E/ s+ ]# W - final int newLight = convertLight(6);
9 F5 b2 h4 m; A. U2 J+ t3 N - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
# s8 |5 |6 o$ n# M! g - final float lineHeightSmall = (y2 - y1);" i' s% B) p) \( ]
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);* `; }& Q, e1 s3 g# P! I! S
- pose.popPose();
% s5 H8 Z! `6 K - }
8 w$ A1 y( `# z
4 ]! h# W1 V5 [. ]- private RenderType getLayers(String texture, int light) {
; E6 S: \ t" S: N9 R3 L - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
/ X! y6 \/ l7 L& X: @ - }. F, a4 B0 Y9 g8 V
3 u; U7 o( s* U ? e2 W% n- private RenderType getLightTexture(ResourceLocation texture) {
6 w2 p4 h9 M0 f5 x* l% g - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
, O6 h! {2 ]: H( C - }/ }0 K3 H* j1 O" R! J8 ?2 B
9 m6 Q" S. w8 ?0 `- private RenderType getTexture(ResourceLocation texture) {# x! ` e9 y% g: {; ?" C, W% x/ l
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);" }! A! q5 T& R+ K. W/ v
- }2 d' s* a4 h3 K0 J: Q8 J2 p
( m# a! k# d1 ?- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
4 d# l7 I. m1 y) L" T - if (cache.containsKey(identifier)) {
( J" g$ B* }7 b' I - return cache.get(identifier);
) z6 z' S# L( H6 _% }- T s - } else {
$ i9 c1 o6 ?5 z- R; I - final RenderType renderLayer = supplier.get();
6 Z# u6 b6 G- }9 K6 y+ f - cache.put(identifier, renderLayer);: j; J5 A$ i, w
- return renderLayer;
, Z: k' z8 `9 D! ]/ {8 b8 y/ A: T - }" r9 @+ P Q$ W3 W* o6 c2 h, |
- }1 S m0 f4 w& I2 j% j+ g
- }
复制代码 |
|