|
|
# U& _: J; {6 p1 v2 f0 n2 m% Y; ~
行,这个怎么样4 S3 X' q0 u6 B& L$ {3 O
- package com.xhg78999.mtrfac.render;9 E) I7 v5 k; O9 Z2 m6 T
- ) T! ^' H0 e& P$ I5 q8 B4 B
- import com.mojang.blaze3d.vertex.PoseStack;
" w F" X$ \! V0 G; d7 K - import com.mojang.blaze3d.vertex.VertexConsumer;
9 K$ |' ^6 e0 `) c' G8 z: f - import net.minecraft.client.renderer.RenderType;4 ^0 V o( b! S+ M
- import net.minecraft.resources.ResourceLocation;
& B7 d) q) [% d- S4 ^7 Q$ y/ M; K - ) ]- C) M8 F5 u' o, Y
- import java.util.*;# f1 [1 ~9 ]6 L: p# W3 I
4 ~! r% h+ a! n% I8 [& `2 _- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
% }: ~7 R# X) ^% x/ }2 _ - + `. V, s$ J' h
- public class LineRender{1 X; G+ C5 g7 C+ U1 i
- private final PoseStack pose;1 Q: y! Z1 u+ Y5 A) J
- private final MultiBufferSource source;1 @) }, X. ~2 U0 \: H
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
0 ?: S* {$ K3 L. s - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
+ q, Z( H8 u9 a$ P - 3 w' |9 g! m1 Z3 v4 Q
o, ~' D9 r- t# E* T4 ]; `8 H- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){6 O9 l! m* ]& P$ Q m
- if(x1 == x2 && y1 == y2 && z1 == z2){
: U" R) w* o% ]/ c+ \, D - return;% q& R: b0 w* v }. B
- }
% Z- _4 z1 Z$ j$ O, H" p$ a$ E - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
- }. E- |5 @* ^3 a/ G% X3 V - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
; f/ a$ [5 \6 H! V* X - }( [7 {. x2 `9 v& R
- pose.pushPose();
4 z! P/ r; g0 X: T4 }$ N - final int newLight = convertLight(6);
- _& p7 T4 v& |2 s - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
& ]# c" C5 ~# X/ {6 D - final float lineHeightSmall = (y2 - y1);4 s: E/ L8 f& h! y2 C f; \
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
; W7 w" P5 i! S5 _5 |+ | - pose.popPose();
/ y* U/ S& \6 i1 [ ? - }
+ z8 z/ A2 d# U+ y
7 g! \0 a9 D# H: K- private RenderType getLayers(String texture, int light) {3 M, ]) d7 \. X- j0 ]1 ~$ Z
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
+ [( I& m; [0 f0 l$ X - }1 R C! z0 ~& T; J4 P
- 6 R L8 u' g/ p9 W
- private RenderType getLightTexture(ResourceLocation texture) {
; t+ q/ t8 _1 @! J3 w) ` - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);3 ]4 S0 y4 S( t# T+ r
- }0 f% i# u, j$ J3 l' i
4 i" ^% L% b9 I. m8 e2 ], ?- private RenderType getTexture(ResourceLocation texture) {
+ o# N! g- H: J" Y# l. y. N - return this.cache(texture, () -> entityCutout(texture), CACHE_B);# p t+ G0 x: M g6 s# Y. p$ K
- }
7 w+ m& L$ J' F- O! z5 o - + m" e$ n. _! l6 J
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {, @( |! d. a3 N1 [4 \
- if (cache.containsKey(identifier)) {$ v$ z, j+ z7 e* B# ?
- return cache.get(identifier);4 {* e9 J) [! ], U, ]" Z1 n
- } else {
! E# Z: }9 R! }3 Z8 M - final RenderType renderLayer = supplier.get();
; F( W5 n! j% T - cache.put(identifier, renderLayer);
/ ~3 y3 L% I4 [ T$ X( n ]! j - return renderLayer;9 A2 b) |6 h9 W, N5 p3 }( Z, z1 j, r# x C
- }0 L8 e' `" Q/ B7 b7 {! B1 C! e
- }
" p" O; p2 ?1 j0 M1 \ - }
复制代码 |
|