|
|
" K4 `# @2 k3 x z
行,这个怎么样
0 q0 R1 S" _5 j o; m2 N; d/ A- package com.xhg78999.mtrfac.render;7 \1 d K) z$ T9 _7 v
- + R$ W, \' r3 x* ]( N
- import com.mojang.blaze3d.vertex.PoseStack;
9 v+ F0 V. o* a8 \3 S' y - import com.mojang.blaze3d.vertex.VertexConsumer;, y4 [6 {3 U$ z: }, G0 G
- import net.minecraft.client.renderer.RenderType; t8 M% \0 Q2 L% Q
- import net.minecraft.resources.ResourceLocation;
8 p$ x1 A$ f5 m+ E
) |+ x- D, n! T- import java.util.*;
7 R* K5 O5 _3 h4 |" t& \$ Q* D
8 S( f) _" U6 ^$ i1 L# A- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
6 r' E- I& l3 ~ - ) d" t* Q# E) r) l
- public class LineRender{' M: c+ c i- N) Z
- private final PoseStack pose;6 Z1 i; l+ L2 [$ R/ ^
- private final MultiBufferSource source;# ~6 w; ~7 N! R, [) |8 [4 o
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
7 x; F# b; }) _ - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();; f6 p1 w; r. y" N- m1 g0 y3 p
- ; ]6 ?8 m y$ U* K- O
* r+ \3 | A( U1 s$ x0 w" \- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){* g- g3 X1 m0 D) z* V4 d
- if(x1 == x2 && y1 == y2 && z1 == z2){8 q$ x. s/ v. p8 V- I: }& N
- return;6 C1 A' o! r. t/ y% T7 k
- }! r# @* C1 J3 I: c L$ b
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
. M6 k* I& p4 ~) ] - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");& `4 g' T6 B- n
- }
- e; Q% e" i( h; @2 Z* h - pose.pushPose();$ X/ G3 o6 r1 L( M$ |, N/ ]
- final int newLight = convertLight(6);- w, n- m4 f' u/ Z
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));; x- n3 }7 ~" O
- final float lineHeightSmall = (y2 - y1);
: H2 |+ E3 }1 ^ - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);& Y: h: s5 |# {3 c
- pose.popPose();
! G* }+ c) E5 O) O9 s( C/ o - }8 V ], j: c4 k. M0 T
- % }; d) I8 p7 L
- private RenderType getLayers(String texture, int light) {! z; f- _2 I2 S$ l% |+ u
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));9 V7 B4 \4 Y" E5 l9 o* I4 E
- }
) K* a& R! N. J/ R+ w# p - . D" Q( O9 w; r0 e
- private RenderType getLightTexture(ResourceLocation texture) {
0 u5 n# I: r+ F5 { - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);( a2 @( L9 p# F7 a e0 L3 x
- }
) Y+ } x- T) r2 E; N
/ q) w# l9 \1 h1 x O) x: ?1 D- private RenderType getTexture(ResourceLocation texture) {
: \+ \% K! B" w% X - return this.cache(texture, () -> entityCutout(texture), CACHE_B);* U* ^# W6 ?, i. \6 h3 q! s6 d
- }
! p; B I1 X B T+ \# f
& K6 Q2 W, H! {$ |( N- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {0 _) \* G5 R; p+ U. z: `3 S
- if (cache.containsKey(identifier)) {
/ T _5 G4 ~; ^+ V6 F+ @, k* K - return cache.get(identifier);, [, }4 H( L+ T& x; w
- } else {3 j! V1 v! d( m, v6 u
- final RenderType renderLayer = supplier.get();5 w; h, _ ]. |# ^' U
- cache.put(identifier, renderLayer);
2 T3 s$ H7 v% K# l) U$ ]" ?0 h - return renderLayer;( r& \2 M# j) R9 C; o3 b
- }
; @0 V9 a) O! i$ P' J, t L! | - }: A4 |. S* c; C$ h. x( r
- }
复制代码 |
|