|
|
6 f, I) d9 j+ D+ h; Z* `6 x
行,这个怎么样4 o& r* S& K* l' g# ^. h$ }# T
- package com.xhg78999.mtrfac.render;5 f; X/ H- ~8 _' g0 X* F
- 6 b8 G* S" L# A) X
- import com.mojang.blaze3d.vertex.PoseStack;2 K d1 m2 U, [# M% k5 ]: ^9 J1 ~) s9 n
- import com.mojang.blaze3d.vertex.VertexConsumer;
6 P( s7 d4 _9 c: C H - import net.minecraft.client.renderer.RenderType;
* F* v# ~3 b' ?* g1 q0 Z0 U7 } - import net.minecraft.resources.ResourceLocation;1 y% E+ w/ U; E) d D S7 V$ V
# Q. S& C$ X: X: q+ O4 d- import java.util.*;; i/ \& F; y& k) _3 `3 T( W8 g
- M8 _/ B0 T( e8 Q
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(6 q7 u$ D2 U+ C z
& f4 ]$ p; M C2 O, D" {- public class LineRender{# Y' L& u& E5 f5 c
- private final PoseStack pose;
) i, z" |) S" ?; y. R2 v - private final MultiBufferSource source;2 Z4 i1 Z3 k6 `4 M, M; y
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();; i# l+ h' X0 [, o3 F
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>(); n0 v: @) f9 H8 f
0 s) Q) ]0 \$ R9 S4 W6 @5 [- 0 o, k3 p3 h* M
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
9 E( A1 G: \7 }( C9 j) p( q - if(x1 == x2 && y1 == y2 && z1 == z2){
+ T( Z$ r+ q3 N2 \ - return;
3 i5 J% b2 Z: g% m1 f: X - }
& j) b9 w2 e8 {' i$ ]& p - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
- O/ I! l8 N9 b2 u1 _ - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");' C8 }( }% p" {7 F' C
- }
% _# T5 w' m0 @: h+ R/ f& s- i - pose.pushPose();
% K% u4 F! {9 a7 H4 _8 G w, Q+ o - final int newLight = convertLight(6);
4 ?' m4 K( o! r0 Q/ {5 F - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
3 W* a, W; `" s - final float lineHeightSmall = (y2 - y1);! E. ^3 b) W& \. h. Q
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);# X9 i: |1 H; \' D# J" I
- pose.popPose();
+ n ?) [! K* r; {. c4 I - }& v% h8 T: |2 Z) g) R/ }! q; d
- 4 U7 g1 D+ f6 U: A d
- private RenderType getLayers(String texture, int light) {
u1 W; u1 G0 c$ ]. V- [% i P - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));( Q, V9 [! C9 e0 d/ {! |; h/ h: t1 y
- }! b/ ~; ~5 B( N
- : O: y1 y1 o, k0 n6 f) A; e. K* v
- private RenderType getLightTexture(ResourceLocation texture) {* l6 W2 g% C* x; Z3 x1 v
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
" B( z& ~6 v; n$ q1 [8 B4 U7 u - }! \6 q+ ^. p! V; n' Y4 Z L0 \2 H
- : F4 S1 O/ m8 K
- private RenderType getTexture(ResourceLocation texture) {' N' P) |3 N1 r0 ^' L4 @
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);7 f8 w# q! d- ?5 g5 p. I9 M+ q
- }
, C+ p& b2 U) ?3 `/ j- ]) t7 \
/ C* w% j$ m# W* u7 H3 I: }$ }- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {' {/ d5 A0 q: W' j" K7 M: M
- if (cache.containsKey(identifier)) {8 `- a* ]6 ], x$ z
- return cache.get(identifier);
1 g7 w9 i4 S2 w2 S - } else {
& ]6 v5 L2 o6 a - final RenderType renderLayer = supplier.get();
2 A' F& X# m: M4 w" M+ E6 v. s3 }: z - cache.put(identifier, renderLayer);
' R! e d+ ]7 a5 x# F1 D, r9 D - return renderLayer;
9 L8 `' q. p9 ^4 C2 n: s# [ - }3 `9 d; [* H+ X4 D4 p: G
- }
% Z/ [" H) c, V' j6 G. D4 J J - }
复制代码 |
|