|
|
9 O- x8 [7 y8 d: U7 P
行,这个怎么样
6 A" `5 m( c) n9 ?- package com.xhg78999.mtrfac.render;$ ?2 z' P. Q2 o( ?/ l' @, _5 w
) Y' b* a, g4 h+ X! |- import com.mojang.blaze3d.vertex.PoseStack;
) n' z% B) {4 l4 y) W) f% F - import com.mojang.blaze3d.vertex.VertexConsumer;
) x: T# e+ _" v6 c" g' Y7 ] - import net.minecraft.client.renderer.RenderType;
6 n% a, ? b7 ?2 E - import net.minecraft.resources.ResourceLocation;
" `1 Q! w J z: y
2 W. a! s( n# N& ?- T L- import java.util.*;2 u! P- X9 d, N6 V
- ; e( m: N6 G- A& e& {
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(2 L& }' l, h) h! O# B8 [8 @' r
f0 o5 u. `% e* t- public class LineRender{
7 i% c! x( E" Q+ ]$ J. u - private final PoseStack pose;* W$ _! h) r. a
- private final MultiBufferSource source;2 }& U% C* g" G% @: H. g2 A) Z4 O2 b* V% Z
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();' }& O, b# K5 J. g( m; _
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
7 Q4 a8 |$ }. r( |# L' y - 7 c# A# D$ O6 S* W7 F" d: e o
- ! f* Y2 ?1 ^. R) n% e9 h
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
& C. t4 T1 }! u. a1 Q9 X, V g$ A - if(x1 == x2 && y1 == y2 && z1 == z2){
6 ? A6 @" c/ W7 [9 H' ~( z- ^+ _ - return;
( Z. ^. l' c4 z! l% b3 {( N - }: h+ k/ a3 E" m
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){2 ?& r& V6 N5 p# w
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");) p8 U7 G1 v+ z$ r
- }: t" T9 @8 F0 o' _4 {! M
- pose.pushPose();
2 z3 K* d/ `- T4 \# Q$ ] - final int newLight = convertLight(6);' ]( [, d/ l8 {6 z( V" Q, O8 u
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));# d/ I9 n. D5 D8 r- \
- final float lineHeightSmall = (y2 - y1);2 z9 o" D2 u+ \ ?- s1 f( V; j
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);( \' w0 m( w T; k7 n$ c& p
- pose.popPose();
0 J# e" E" M/ X: s - }' }1 ^; {' V% `. s$ R
- d, F3 U9 t: i* E9 ?6 Q- private RenderType getLayers(String texture, int light) {
" [. f( b7 W, b! f0 _ - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));( Y" Q8 P8 c1 O- y. A6 z" @ d. i) }6 ]
- }
1 D( t: ~5 \0 F5 O# E" Z - ' A' z' o. z" R: k, M+ m1 P
- private RenderType getLightTexture(ResourceLocation texture) {9 f# ~, y: Y/ }9 e
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
; Q& m9 }) u& r - }- [2 T5 V+ i3 W" l2 V0 }# p9 ]1 J
0 r3 S0 m3 r% ^1 O5 v' H c# \- private RenderType getTexture(ResourceLocation texture) {* d- e( y" z; {8 n1 l R# ^
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);1 }( c1 b. P- O" I t5 J
- }
/ c/ B4 }; M2 r |; S1 U
6 l( c+ H+ c8 i9 T6 R! x- u- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {2 m3 t% g# a0 n) u2 V+ p
- if (cache.containsKey(identifier)) {
8 Y" a: P, r: j% C$ }- i1 f - return cache.get(identifier);1 Y1 O7 [% I$ [) U4 @; }( p8 f% @$ F
- } else {
% E5 J3 X g( u2 \( A - final RenderType renderLayer = supplier.get();9 [5 Z9 T6 a7 _; X8 T+ b9 }+ o9 E; ~" n
- cache.put(identifier, renderLayer);
8 l6 ~9 x, |: y, I1 C/ B - return renderLayer;
2 ?# Z0 Z0 w4 M9 T - }. ` r, t: I' O: W, o
- }# q: X9 v1 t& D5 j' S5 B4 u
- }
复制代码 |
|