|
|
q! G1 d; i. B, R5 } D行,这个怎么样( D. x: y/ O" {- b# w
- package com.xhg78999.mtrfac.render;9 {+ K8 u7 X2 T m
- - i; h4 t( o- p
- import com.mojang.blaze3d.vertex.PoseStack;
P7 ~, {# s2 E# i) |/ w - import com.mojang.blaze3d.vertex.VertexConsumer;# Q4 p) g' J% ~# |
- import net.minecraft.client.renderer.RenderType;" Y4 f. m: M! ~2 @6 h- L
- import net.minecraft.resources.ResourceLocation;& ~! ~. i m4 e3 {; @6 i
- 8 S. m+ A2 @2 O" S3 k
- import java.util.*;, u# m; d$ I, J7 W
- / I0 e2 p( J. e! @7 R3 {% S
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(2 B8 ?$ r( P' ^9 k5 W
- ' D& K$ U4 L9 C* |8 x
- public class LineRender{
2 _, X+ {4 @$ r0 P; `8 k - private final PoseStack pose;) E- ^/ V5 T8 O w' a) R+ {
- private final MultiBufferSource source;
! v( [9 r. B/ y! [" t6 k - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
% r5 e8 H3 Y/ r$ P - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
( ]9 |0 G4 P9 [, c3 P% F - + O# m9 c! x! \. d; U; O
- U+ w1 d# f; o6 d6 N$ u! l- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){5 u. M' a2 Y( I" b% J
- if(x1 == x2 && y1 == y2 && z1 == z2){/ m- B1 n; B" v. z
- return;# v8 x* X) G/ Z' [4 _0 n9 k
- }
- I! F2 h- V& q& H* E. Z - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
/ c7 j0 u9 x5 }0 n+ C) V - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
% N# j6 R0 O8 ]# S" `5 C - }
8 ]7 i% a9 ~+ x - pose.pushPose();
! [9 V, x% {5 K5 `/ u9 W - final int newLight = convertLight(6);
0 ]& T5 I) l3 ?; _ - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
# |% ?+ I; o m$ o$ d6 e - final float lineHeightSmall = (y2 - y1);2 m/ f K3 Y* x* U
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);/ C8 h3 p! p4 \& b. I3 R: ?
- pose.popPose();3 [0 T3 u% ^* ^2 Z; {% A
- }# o" x* o8 m! f5 `: W
- $ j9 K. m g& x
- private RenderType getLayers(String texture, int light) {3 o! `+ O9 ], C2 d) x. s
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));+ f# O2 t. G \) j) A. J
- }
8 f$ o& F% E. E- g h$ a9 n# x
7 n R) J! Y- w$ j0 e- private RenderType getLightTexture(ResourceLocation texture) {
6 {4 @8 g- H1 G+ h- J# ^" t - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
- ]& H1 X% U1 \. m" R- O1 b+ Y - }
! ^5 g8 k* l8 K; _0 I! A - 0 H& w5 g+ O9 Q: _: K, X* |9 U: j
- private RenderType getTexture(ResourceLocation texture) {% q3 x0 ?! N! D4 ?4 r3 T) `
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
2 F( b% p* J N2 y' } - }. d, W* @+ k0 u' o$ j
; k: d& [! V4 {6 {7 \2 S$ Y8 w- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {) j- O& P, }) X& A/ p
- if (cache.containsKey(identifier)) {
& C! R# I/ t, E" c - return cache.get(identifier);
4 M3 W0 W( Q K$ V5 z - } else {
# k* X# p: n2 l - final RenderType renderLayer = supplier.get();! Z+ d9 t' N2 ?
- cache.put(identifier, renderLayer);
+ g! V, Z* o# n4 p; ^+ t) q y - return renderLayer;
. O- T% `6 U8 v- Y. F# e - }. r" R; J$ Z& ? a# l: _
- }9 o! P1 t* y1 I( o9 e
- }
复制代码 |
|