|
|
' ~1 [8 \9 R7 Q) H" @
行,这个怎么样
* Z. v1 q! v! B3 g' t- package com.xhg78999.mtrfac.render;
6 U8 M: y$ Y& s. i/ [9 W
3 s/ A- h, g3 f* \& s* i- import com.mojang.blaze3d.vertex.PoseStack;/ x) G2 b' |- {
- import com.mojang.blaze3d.vertex.VertexConsumer;# L- B5 i( r7 C' z
- import net.minecraft.client.renderer.RenderType;
+ n. ^3 ]7 f S& Q. d* ?7 F0 { - import net.minecraft.resources.ResourceLocation;
2 [+ {, z9 u- I' b
5 O6 d4 i _4 C- @2 {- import java.util.*;
/ d, W% ]4 h2 P, {& t4 T0 o - # g( D" M2 t0 H6 {# R
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(0 o; z3 c" `# z: ~6 p
" C% X4 E0 J4 V4 Q- Q; g- public class LineRender{
/ q2 L+ ~+ h) `4 H1 r$ i - private final PoseStack pose;- U, Y4 u6 n/ d" n# L7 S, w' @
- private final MultiBufferSource source;
* l0 p+ v8 b8 G+ Y! v) l! ` - private static final Map<String, RenderType> CACHE_A = new HashMap<>();, C! q+ q! t3 [: A3 B, M. G5 r
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
4 e/ s& @! D7 b ?8 A; n) L" x) H" B
" z, U% Y" p- n- * T$ \# X; l' e: o
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
2 ~8 `6 a2 |+ F1 R5 B$ I - if(x1 == x2 && y1 == y2 && z1 == z2){: m2 }" P. Q8 x% q/ M% |" e
- return;) j6 g" W0 V" z
- }
" X4 v$ J3 K" t5 V2 J8 h - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){ n$ ~ k0 G/ F0 n4 @8 l9 V
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
- B2 p4 w, u# i: W - }. ~7 `# r8 I% h. Q; i
- pose.pushPose();
3 a! V+ e* }4 }5 C6 Q3 }: s - final int newLight = convertLight(6);* Y2 ^. F9 G* D5 H
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));' |8 z! h: j7 X
- final float lineHeightSmall = (y2 - y1);# e' X5 j* G5 q) z
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
; s# h9 i5 V, A) z- l - pose.popPose();% D0 L0 B z3 L. ]1 B
- }
, \" I/ W( b* h* H% n
/ {$ k/ B _* E/ r7 ]) P4 X- private RenderType getLayers(String texture, int light) {0 Y; A W( D2 X& c9 k$ A. ~ _
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));, S# ~+ ]& T5 e) U
- } m7 q: n$ P7 W3 ^# a/ p% N/ ^
7 G/ v* l0 v8 ]) s- e- private RenderType getLightTexture(ResourceLocation texture) {/ c1 u" O, ]0 u5 @4 t4 A0 c
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
# a& @+ F" a" {: N: z0 E _+ ~ - }$ U( n3 s/ S4 p8 K" @1 {. N
- 5 P, u! R; y" ?
- private RenderType getTexture(ResourceLocation texture) {9 X7 R6 z' Q. w
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);& V# A' o8 E9 B. J& n5 C
- }5 a0 W4 c" U# S* w2 Z9 d
- - Z3 ]' ~: S* \7 p/ ?2 l
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
% }9 ]4 t) t& D$ d9 N1 t - if (cache.containsKey(identifier)) {1 ~* b* k, }4 p
- return cache.get(identifier);+ T$ Z: t& t0 r3 s$ ^
- } else {9 p9 t D/ X3 F
- final RenderType renderLayer = supplier.get();0 a) f7 o4 h, ~8 k+ `
- cache.put(identifier, renderLayer);- I% }4 E1 P/ J) h4 {* }0 v
- return renderLayer;: J8 n, h; L/ R3 G" j2 T/ n
- }
) ?, V2 K0 U( W0 a - }
2 m: d. [- _$ B4 g: i7 j6 e - }
复制代码 |
|