|
|
1 z* i8 D% l, E/ \7 N ]/ d ^行,这个怎么样5 R" C# H% x+ Y! R, \' S7 U. U
- package com.xhg78999.mtrfac.render;, i4 b6 r! [* P p3 f! I
& ]9 Y: z8 i a% H/ ~ r- import com.mojang.blaze3d.vertex.PoseStack;$ E2 |& M6 o: E$ {" P0 F
- import com.mojang.blaze3d.vertex.VertexConsumer;* ^9 c1 O5 H' \& U- V
- import net.minecraft.client.renderer.RenderType;; u5 |1 \8 M2 v6 S" Q1 u
- import net.minecraft.resources.ResourceLocation;! B% f1 @* E# C' w" o
6 g* Y4 R# y" R8 F- import java.util.*;
, v4 X6 M% ?) ~* {# j3 O7 ~
% ^" z; J( ^! ~' Q. z) A. v- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(: }. H& k+ f, U; u" A+ { d
- $ z" B p1 ^5 ]' z6 O6 }
- public class LineRender{
# ]6 i1 g) n; i. e6 W - private final PoseStack pose;
- l& w' t' ]: m* b. b) F$ d - private final MultiBufferSource source;
. X# c! D7 y7 ~$ X" N9 v- {& ]" Y - private static final Map<String, RenderType> CACHE_A = new HashMap<>();4 l4 i3 z% @! Z M2 g+ y6 G; `
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
: c& |* d( |4 u0 R/ }1 r
# x( M. |4 _6 \7 w4 Y% ^) Z
i0 {9 E" Q! ?) t$ @: ~- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
) @0 a. S, E5 L* A* F1 @" n6 Y - if(x1 == x2 && y1 == y2 && z1 == z2){( c0 S2 o& C9 R: U" `
- return;
" D# G# j+ Z0 u - }
0 t8 h) q0 Z t( e/ E V) g7 x - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
3 B$ {- |# D/ k) n; c. F( R - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");2 q& ]) ]& V7 x
- }/ n# B" ^: F) C* S$ p
- pose.pushPose();% [3 K& x8 v" ]" P- X. Y+ n6 P) c: E
- final int newLight = convertLight(6);
9 j' b- ~+ |; `5 f. T" L8 C; x; Y4 P - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false)); q9 y, D9 r% Y: u
- final float lineHeightSmall = (y2 - y1);/ r% z6 [4 D1 f6 v
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
8 Q/ F2 D1 _# R& x- Y1 v/ A, j - pose.popPose();- y* K' O+ I/ @ ^1 u$ v& N
- }5 S6 u* L) w8 h/ H: L: z
+ K; d# d+ D4 W+ L4 q. i9 _- private RenderType getLayers(String texture, int light) {
5 X2 H( L( e# S) V5 B - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));% l/ I8 ~+ s1 f+ l9 W# m: m+ y
- }
7 p5 M4 { L. N1 b7 f
9 i9 |. k1 U2 i Y7 O- private RenderType getLightTexture(ResourceLocation texture) {7 f" y/ u. {+ J$ z7 o
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);) r- S3 k7 M" t
- }7 K0 [: Q# ^" {% e
; P5 k, X9 T7 `8 g- private RenderType getTexture(ResourceLocation texture) {
. m3 r9 R5 ]- A! K, {" ] - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
0 I! a! B# y8 s5 P - }
/ l1 H: c1 G; Q - 9 H& }( M8 a& y# D+ s" D
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {8 e' b; u( B0 s! L# [ K; F
- if (cache.containsKey(identifier)) {
; q$ N, H: L, M/ [( K - return cache.get(identifier);9 h6 ^; d6 @2 s5 |, Y! I& h. T
- } else {: ^9 `6 P* @% O' t2 o* |6 f3 E
- final RenderType renderLayer = supplier.get();
) }8 ^: y1 P) w. X0 ? - cache.put(identifier, renderLayer);& d: S) z" F" V& v
- return renderLayer;
% q2 T. w& S6 r& v6 l8 L! p - }
9 p) J* J: S5 W0 k: c- A) z - }
?6 n& ~3 B& I, u+ }4 N0 E, z - }
复制代码 |
|