|
|
, t7 J( G0 l3 ?8 L }) d行,这个怎么样+ O& ?# k. x4 v7 n8 t
- package com.xhg78999.mtrfac.render;
; h% t* _1 t; m e4 u( P! d5 Z. |
9 v- B( U# {5 B; I) v; F! A! x- import com.mojang.blaze3d.vertex.PoseStack;
" |1 T+ i, K7 Y/ X - import com.mojang.blaze3d.vertex.VertexConsumer;
0 q! L- @( C% a$ O- `: e v - import net.minecraft.client.renderer.RenderType;
% o$ o5 p: S* n5 ^ - import net.minecraft.resources.ResourceLocation;
( n1 i" N/ `1 X9 h. o2 P
/ m$ y9 J# q7 m: M0 R- import java.util.*;
! J6 L& m8 {6 f - ! M) B- _- E/ n! D6 f. c
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(% R1 J: Q) [7 p6 ~* g
- 7 C# f' W5 N* _
- public class LineRender{
6 R0 r9 ~8 ^2 N; F4 o - private final PoseStack pose;
( |/ j- X$ `. C - private final MultiBufferSource source;
! A/ C7 V4 N u2 J ` M+ F - private static final Map<String, RenderType> CACHE_A = new HashMap<>();2 `1 \/ b! s. P1 W" S9 I
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>(); R% x7 L3 d% J8 u+ Q/ S
- - g8 v* H% M" p" B1 A9 ?" F
- 2 j" M% @. B/ r, c+ g2 J' a9 ~7 Q# R
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
$ h3 i! n' L( W7 Y7 K - if(x1 == x2 && y1 == y2 && z1 == z2){3 q+ L6 U+ o8 u, t" U, |9 D
- return;) |! b! U8 L4 U- ] ]3 n$ h
- }0 c* H6 `( k$ \( V5 S6 E
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){3 ^( G8 o% x1 b8 D) d; G+ X
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");( w- ^ {7 a" G4 i n+ S
- }( r+ d, x& P, T! s
- pose.pushPose();
# k5 M: r8 ], ?! [+ s* B - final int newLight = convertLight(6);* p) r9 V' h" z' }2 i' ^3 P) q) p3 w7 ^
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
& X' |5 j" u# y) l - final float lineHeightSmall = (y2 - y1);
1 T9 l9 `: \9 q - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
' b: y$ Y. u; I# T$ r9 m - pose.popPose();! A6 ~7 q: ~5 m- f
- }! ~# S; S8 j9 l# y5 X% g# X7 j% h
5 o) p- o. K$ t0 c0 d- private RenderType getLayers(String texture, int light) { y" ?, Y! J1 S/ [8 l
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
# V$ j+ T% |+ I1 K4 | - }0 W8 P2 E- f2 F9 {& H! H# R, }
% _0 F6 u! v# M' M1 u/ x2 }/ e) V4 q- private RenderType getLightTexture(ResourceLocation texture) {9 L% V2 h2 |0 i( N9 t
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
2 q. n& w5 p G; W/ q- }4 l& R5 p: S - }
5 R: e( ?/ [" w2 @( t- l - 8 P$ m! D9 @+ b+ k
- private RenderType getTexture(ResourceLocation texture) {, s$ X9 F9 B$ i0 L0 ]. T
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
# K _+ ]) X, o" V - }
4 _+ y- A" }4 O5 f9 Q8 `% w - 0 d: L! M+ \' R' I8 \# ?2 c5 a
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {% C; i( T, h' S
- if (cache.containsKey(identifier)) {
& G7 [( @! [" W" @ - return cache.get(identifier);6 E' Q1 Q# [/ P+ ?' ?) \, s3 U9 s
- } else {
. q/ _6 l! n# @7 e$ k- B - final RenderType renderLayer = supplier.get();
) ^8 x- Y9 [( R1 L - cache.put(identifier, renderLayer);
7 b3 U) ]2 \3 X; a - return renderLayer;; g# k: U* ]7 g8 U
- }% Q+ X3 ~9 h# ?9 h& F6 K2 ]
- }, @( D( n7 b$ w3 W# v# h
- }
复制代码 |
|