|
|
7 \2 p& [1 U5 Q# Z4 C" [/ G2 J行,这个怎么样6 g D* _2 ^' R
- package com.xhg78999.mtrfac.render;5 _% a5 F: |' A" U/ T) b
- ! I g5 S& [- O
- import com.mojang.blaze3d.vertex.PoseStack;
& X: z, B5 @- u$ Q! i/ H3 } - import com.mojang.blaze3d.vertex.VertexConsumer;8 z S4 a$ ^3 S* N$ i0 E6 U2 ^
- import net.minecraft.client.renderer.RenderType;
6 e2 v I0 L( F - import net.minecraft.resources.ResourceLocation;3 l1 E {3 i+ K- h3 n
! q; H8 F/ m5 ]) G% ?& b- import java.util.*;
+ ~) |2 U8 u% w$ P% f4 ~
7 \4 x( b6 |8 H- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(- @* W4 g! B- L
- 4 {2 S) l; b- P* J' b/ S' K# a4 u: ~
- public class LineRender{1 ~" |/ X7 b/ X: x: R* j* k
- private final PoseStack pose;2 I6 R+ D% G+ Y& Z; G/ o8 T
- private final MultiBufferSource source;
* m0 O" D9 Z1 i - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
) Q$ O, E& I- g8 A' c7 @ - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();6 J& h8 s; I p; N5 Z& P4 u! S `
- # B; j* b5 Z, A& s2 J7 \
& s- y/ I+ b" P0 u- e- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){1 D" T6 }9 [5 l+ i
- if(x1 == x2 && y1 == y2 && z1 == z2){1 ~. }; S1 e; i/ C5 ^! |2 M
- return;
0 D9 [; J4 s* B2 M0 c1 I Y t; M! u - }
) q$ l7 Z3 i. w+ N; w. b3 X9 x& ~9 w - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
6 ~* y% `4 j; W! e( ^0 B% J: S7 A - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
. P; d1 {- H/ g - }
8 a" Y- M8 x3 i5 u - pose.pushPose();+ b2 F2 D! G6 ~& c- t5 n% w+ w: o
- final int newLight = convertLight(6);* _$ p' `0 G9 n" X$ b
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
1 K1 D% }" p" _, [, L6 f. G( d - final float lineHeightSmall = (y2 - y1);" Z0 B$ B9 n6 v: O6 V P
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);! ^; ~' ?1 p9 S @7 d3 \& G$ L
- pose.popPose();% A, w) m3 I; L1 j
- }
' Z) i+ E$ Y8 U$ S, F- m0 O3 q
; n6 H" W f4 w- private RenderType getLayers(String texture, int light) {
! d- H" B, p' K2 K4 \ - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));9 w) V$ H% H9 ]. F: r- _# Q
- }5 |% {4 ~% w# R% y. v2 t9 c
- 9 a9 q9 F" J8 R! N8 S0 w
- private RenderType getLightTexture(ResourceLocation texture) {
$ [1 @, Q: e* } - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
9 q3 Z& g& ?+ f# ?# P) A2 N - }+ J; c# t1 k- E7 x# M
, O. ~2 a* q( `; i- X" ]3 L; v$ }- private RenderType getTexture(ResourceLocation texture) {% ]8 P: ^- `7 g+ w
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);7 g* g$ x, N1 S/ V4 A
- }
4 H0 K" C& ^6 T
4 i9 O! Q0 L9 v* a* p% V2 }- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
; x2 m/ c& v8 w8 p) c - if (cache.containsKey(identifier)) {
8 [5 f0 e+ X. [# U7 |) U; n - return cache.get(identifier);
. `! L/ ?9 p3 K6 Q, u - } else {) U6 o8 h3 W+ i
- final RenderType renderLayer = supplier.get();; q- H# S. E# {1 s7 f: T/ k0 g8 O
- cache.put(identifier, renderLayer);
; I% t9 Y' o4 C2 G8 p% V0 }, c - return renderLayer;$ y6 k" U" ?' G" M
- }
& \8 M! W# x( p4 O# W$ s - }
4 S4 Q+ U- x% t - }
复制代码 |
|