|
|
- m$ y% c3 O! r4 ?行,这个怎么样) f6 k# Q( U! B" r. |7 T
- package com.xhg78999.mtrfac.render;* J5 D% M; y9 {5 e- r _- t
- / {. j. d( J/ {2 v! d; ], C; Q
- import com.mojang.blaze3d.vertex.PoseStack;4 \, v% H' [% |- p- |, b
- import com.mojang.blaze3d.vertex.VertexConsumer;
, D2 T; w" R. o - import net.minecraft.client.renderer.RenderType;8 t1 [4 V' B( s" r
- import net.minecraft.resources.ResourceLocation;) t- g; b( S& A( ~* Y: @# y, n9 v
- # P8 W/ D* f+ p+ m- W9 J
- import java.util.*; s2 O; F3 Z, y* g( ~
8 S& U7 n; T, b6 J% P1 ]$ {$ Z6 _- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(% c9 k5 { g& v" A" B4 ]
- , S U7 X. U, B
- public class LineRender{2 A/ r! U( o2 }/ C0 {1 w, \
- private final PoseStack pose;
% M( }5 }( O2 W- j: C: o7 w - private final MultiBufferSource source;
) R) e1 N) g: O2 M - private static final Map<String, RenderType> CACHE_A = new HashMap<>();/ B* X+ Q9 }( {: K, b
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
) y" D5 B) \; i0 _# F7 W) m3 c - 8 Z0 m/ L( k6 }; R1 b7 `# ~
- . T1 S' l: x3 V4 N2 [3 h6 d8 i1 m# z
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){% C$ ~8 ^' n0 w2 j" `+ F8 T
- if(x1 == x2 && y1 == y2 && z1 == z2){
% o. [& u* i) w5 |2 [ - return;
8 v1 w0 _' f0 {- ~ - }
; s) s6 B7 Y u2 @! ^& v& B" h* _ - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){4 K. M, P0 g) `; ^
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");9 I1 @/ h5 h9 Z. E
- }2 L1 y- V9 ^+ z; m/ m( \
- pose.pushPose();
4 r' m2 A" g7 m/ |" z) P5 ~3 J - final int newLight = convertLight(6);
5 @7 ?) f0 q& t. H' L- |; t) o - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
+ o- a: U, O7 ^% O- A, R) K - final float lineHeightSmall = (y2 - y1);7 @; @. X7 @& m5 a' P! Y
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
+ Z; K! P' f% h5 k3 E- m0 |% \) o$ V - pose.popPose();
/ J$ Q, p7 }8 z, b0 s+ Q# \ - }
* ~1 G U" `# I/ ]; z
. |; k# F! d5 u6 R8 ?2 [; c y- private RenderType getLayers(String texture, int light) {
# T* d8 _9 P3 r. m! y& t9 g A - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
4 i) t# c4 M- I& f, R) Y | - }
! O' W; |$ ^1 T5 _4 j; @/ [* ^: S$ T - 6 h( Y6 i1 `7 v- k3 O4 P
- private RenderType getLightTexture(ResourceLocation texture) {
- B: P. M: d) ~) R* q - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
. r! [' \8 D3 G L$ Y - }
6 P/ S7 n @( s. X" v# B V6 N, A8 U
* _( |. x$ M/ X7 ` i% M- private RenderType getTexture(ResourceLocation texture) {) k& A [6 X. W% Q+ d8 T& C
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);' |8 S% e7 Q! |
- }
- i F) K) N' c! g, x/ z
+ a+ T) D8 Z1 |& }% d9 p# [- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
) s9 ^! b7 G* K5 _ - if (cache.containsKey(identifier)) {
: A$ c. `$ B) M& r) y/ H5 q - return cache.get(identifier);; z+ ?% E' C/ b/ z/ u. k
- } else {
$ j' y e) f# |+ V9 F - final RenderType renderLayer = supplier.get();
: F3 I/ S" h' P- `8 P - cache.put(identifier, renderLayer);
3 g! r( Y3 A7 T9 b - return renderLayer;7 v2 D ]3 S% f$ r8 U9 \
- }) h' {4 ]6 h5 ?
- }
5 L0 I. M4 V( f! r - }
复制代码 |
|