|
|
' p& i' @7 V- m2 M# h8 R
行,这个怎么样) A7 I5 D/ I. Z. b. Y! _
- package com.xhg78999.mtrfac.render;
+ N, D6 ^0 M1 R$ I - ! S. n$ T7 r' b4 B7 [! g
- import com.mojang.blaze3d.vertex.PoseStack;6 y( s6 M, X9 e2 ~4 a# N4 k) o& E
- import com.mojang.blaze3d.vertex.VertexConsumer;6 |. G( s5 t6 q
- import net.minecraft.client.renderer.RenderType;
% U& V3 r! O$ F - import net.minecraft.resources.ResourceLocation;
+ v1 j" h) H' V' N6 k6 c2 ~ - " U6 W$ }5 e8 H& b) J" N
- import java.util.*;% o( z# |# C, ^! k5 H% j6 C
5 y- l6 @0 K' u F: Y: {( C$ l% [- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(: {" v y0 W+ F
/ j" Q6 ~3 i1 D: n/ G: \- public class LineRender{
: ]/ q! _0 D8 { - private final PoseStack pose;
# ^) ~( e& J N3 W7 s - private final MultiBufferSource source;$ J0 I3 G( r8 \3 y- j2 I
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
# M% n" a' [3 b' w7 v0 |* U - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
6 d7 u* D9 M" K - * [1 [: S( b# K( B" t6 d
- d# m' b7 ?2 @* h8 W$ I2 y- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
7 N' w1 E) t) V - if(x1 == x2 && y1 == y2 && z1 == z2){
3 e2 K3 p3 X. F& ` - return;, m- j, S. X1 b6 q0 U) Q8 N: e1 |
- }
" m9 {" A0 K/ j4 u - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){: z M5 K; s" {7 l. j! e) b
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
- P$ W7 ~& z7 w- s5 M% w u" N - }
+ f/ N; H4 n8 B7 o9 ? - pose.pushPose();
1 Q( `. i8 g% i. s0 a - final int newLight = convertLight(6);7 L/ Y5 }) m) A: F1 k
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
& V; a' L$ q6 ] - final float lineHeightSmall = (y2 - y1);
, }" t" ?1 N* o h# N- h& | - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
2 e/ [) L# A9 q* r2 P2 ]7 w o - pose.popPose();0 t; C8 u; ^- S1 V4 @
- }
- X, j* y/ D7 V) ~7 p" X- U - 7 T9 N: h p- m. j
- private RenderType getLayers(String texture, int light) {
$ ^" D" B3 z% {. _. j! |# p - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));9 I9 |! p( n1 u" d- r
- }
2 _: E; @5 C1 i) h
" {/ m8 y7 i5 H) [! W1 z- private RenderType getLightTexture(ResourceLocation texture) {5 |# h+ R( H: P! [- f: F/ U/ D
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);# o/ \; n7 Y. J9 X
- }
4 e0 g- v1 v. J3 |
, h& ]% m1 D4 d- v% q& q/ t5 `2 i- private RenderType getTexture(ResourceLocation texture) {* G' e/ L4 I! H; k2 E* B; m) w8 L
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);' s8 x2 H3 V7 M7 `
- }
- @/ \% M* y( q ~$ k8 A6 i - * D% t: P4 B1 H4 Q9 L3 [8 }" P) e- \
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {# D+ v8 U& J7 o, L: u
- if (cache.containsKey(identifier)) {% L6 s0 h; m* p" w$ @2 x2 p
- return cache.get(identifier);
6 g, T$ g, m+ O" }0 x4 v8 D. c - } else {
# J% }% S- b0 q+ y6 i9 w! k' n% f - final RenderType renderLayer = supplier.get();
3 f6 p6 R# Z7 F8 G0 t) I- p - cache.put(identifier, renderLayer);
7 U: _* R# T/ S" {/ V1 S - return renderLayer;3 \* i9 U# `; |0 a5 j p
- }
' M# e4 g& g5 `: }) h: @ - }) F; ]+ _) N1 r% O; E$ a
- }
复制代码 |
|