|
|
9 \- p0 A |1 o" t! n/ j. r
行,这个怎么样; S2 m& w1 N& E5 O. f$ G
- package com.xhg78999.mtrfac.render;
) Y- K. ?: R2 S! l/ B5 w. t# i9 q1 T5 V9 ? - ' Y F, a% o' Z! j
- import com.mojang.blaze3d.vertex.PoseStack;
6 x, [9 t$ {4 U: {3 U) c+ L( a: I - import com.mojang.blaze3d.vertex.VertexConsumer;/ l2 {: V/ w$ F% h( w5 [: v
- import net.minecraft.client.renderer.RenderType;+ X+ D; j, p. z d1 W' |1 ~
- import net.minecraft.resources.ResourceLocation;9 T9 C4 m: C1 D" a) u" _
- ; J" o k% E3 Q9 k; j) s
- import java.util.*;
) F) t7 |& X& O! m. Z' B, {6 z - 8 K4 i+ F W: k1 b2 E
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
6 q9 [" b/ h" O# d1 m# M$ F) m - ; Y* Z! o6 }' s. f' ^2 T
- public class LineRender{
- Z( N2 I0 }: @/ ?! e - private final PoseStack pose;* k$ V) W- D7 ~' P( A
- private final MultiBufferSource source;7 ~' {+ Y- X& v) }2 X9 g
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
' T5 k/ `) Q# r9 v9 Y - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
: T4 h2 g$ N; s4 Y0 n - ( d# b4 D) P3 K o# G( `8 B
9 z5 H/ S' W# V7 {$ t+ h- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){+ R1 H$ i* H) k, F6 j
- if(x1 == x2 && y1 == y2 && z1 == z2){
( T, Z& A1 K1 R - return;
! A! C# a" }2 f7 H* L1 H! e* @( g0 @ - }
) J+ n5 x2 k# { - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
: E# U) [# u5 u( b# s5 U - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");! a- U! F/ Q( |6 d) H9 m& D1 Q* V
- }
( p3 Z. K6 d, Y5 m( x3 D - pose.pushPose();
! l; }2 X$ {' Q, R' g" p - final int newLight = convertLight(6);
+ q; H0 W: y( r - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));$ s. I) `. h$ A" Y9 T5 v
- final float lineHeightSmall = (y2 - y1);
9 ?9 X( w1 l* Z4 X* i" L - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
# I' T. l9 P, z8 B& D# X& S' D - pose.popPose();
7 n! o4 m2 s) L, ^6 i/ r- T) s - }, G* U) `# m( O
" `4 J" o! M! R- private RenderType getLayers(String texture, int light) {
; s, F' B# @/ g$ w - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
5 L2 b3 u8 q8 n - }/ D* R& j/ ~2 }6 u3 i
* h6 z1 p- l, N" j6 I' M- private RenderType getLightTexture(ResourceLocation texture) {
$ I# ^2 ~% k$ m) j - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
) O# k! J0 e+ S3 w$ P: }. \. m8 ^: { - }
- R% m9 `& m2 M0 d/ O; n
: K, x# }& B r' G9 c- private RenderType getTexture(ResourceLocation texture) {
$ j& O9 [/ Q5 g" j - return this.cache(texture, () -> entityCutout(texture), CACHE_B);$ ]* n) k6 X2 V* Z( u
- }
7 H3 ]5 r7 i- R8 B5 P9 | - # H5 z9 I* Q" D4 Y3 _7 A, E
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {6 G/ W2 n' l; w
- if (cache.containsKey(identifier)) {# J' C1 Y' o4 A# g
- return cache.get(identifier);
6 E c3 I3 m7 y - } else {2 a) K6 n% T4 L
- final RenderType renderLayer = supplier.get();
, q/ o+ d# R. U) G' w. B0 ~ F! Z: K - cache.put(identifier, renderLayer);
X8 S+ \0 l0 ]' Z9 N - return renderLayer;; K0 P$ M; ^+ w4 F, [' X% S
- }
8 ^8 l3 C0 l1 e& y0 a - }
0 \& N d- }/ n% H) s2 p - }
复制代码 |
|