|
|
; }5 N8 ?: P2 |
行,这个怎么样
7 \: ^; l/ I) j/ y" l9 }3 x# ?- package com.xhg78999.mtrfac.render;6 \7 \( \, u' t& V
- + l' y' N' {- b+ Q, m
- import com.mojang.blaze3d.vertex.PoseStack;9 e4 r0 s4 z- f- S; c) @1 W+ a5 I
- import com.mojang.blaze3d.vertex.VertexConsumer;
( d8 o7 }+ k; g9 E: r" F. A- m$ d - import net.minecraft.client.renderer.RenderType;
/ O. [& n4 r& ^ - import net.minecraft.resources.ResourceLocation;( |/ f' f' D* A" g6 q
- 5 `1 ^( s9 r6 f+ p, ~
- import java.util.*;
9 f. f. g: X' w6 [# R; f! ?
! B1 s8 @1 w; L2 x/ ]# k# J' M# [9 k1 J- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
% f' w9 ]4 Q. x( l1 L
4 `1 R/ e9 e9 o1 u% U3 I- public class LineRender{% {; C$ @+ r' {$ X. G1 [
- private final PoseStack pose;2 u6 i4 ]9 A, L; w! \
- private final MultiBufferSource source;
. _# p) t! ~( G- k* r2 H - private static final Map<String, RenderType> CACHE_A = new HashMap<>();& b. m# M/ C* }% I* e
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();9 D" }6 |% D- t- q7 a/ o
- ( n0 O/ |1 D7 i, t6 U
9 V0 D# [! k+ K- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){( o( F* a4 ~8 k5 h4 ~! ~
- if(x1 == x2 && y1 == y2 && z1 == z2){
3 S! ^1 X. U4 h, u+ o - return;8 o1 ?+ y/ K% O
- }) W. P% X8 [' G( Y+ `4 @
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){: t6 V" g: s- {+ Y W- L4 ?% m
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
$ H" ]" a) p; J5 T1 T - }* [3 F7 r$ r# J' K4 k8 U
- pose.pushPose();- k9 I% `( r* {5 ^4 }
- final int newLight = convertLight(6);
6 T, M1 M# }' O# t( d# B7 R - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));" {( n( f! q& U6 B% o/ E% \
- final float lineHeightSmall = (y2 - y1);
0 T/ Z$ Y* T8 i9 V D: h - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);. ^1 T& c4 g# Q& F' \1 Z3 x. J
- pose.popPose();$ g% Z( W. |" i/ u; K P
- }
8 T. G) o0 M8 O& P3 q# ~
! I0 S. C% z4 j O: i- private RenderType getLayers(String texture, int light) {! l* c* `' N g) k1 x4 ^
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));6 M: Y! W! M- {: Y U5 ]
- }, }9 T. ]( j$ O" ]5 W! o7 }7 j8 u
- : M$ s5 ` n7 S7 j) i
- private RenderType getLightTexture(ResourceLocation texture) {- ~( @- d& c. C3 {
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
! O( U' ?: i+ M1 z/ | `% y - }
/ O) Q& i' [% a1 a; [1 T& E+ { - 6 L% J* r" \9 G3 g; A0 T
- private RenderType getTexture(ResourceLocation texture) {
G6 }! e3 t0 x% P - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
* j; P8 @. f. J, ^ - }5 {* D4 D% Q2 B1 Y- s; l( }
- * T) d8 y! I' ^) M; }
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
0 K/ c: T7 M- D9 p - if (cache.containsKey(identifier)) {
2 S& Y. L. M$ K1 r - return cache.get(identifier);
, V) f, @, {' t4 }+ ]2 D - } else {
5 I7 @; ^0 I, i* ] - final RenderType renderLayer = supplier.get();+ `, Z( F# f& L0 u
- cache.put(identifier, renderLayer);
" t* j3 T& I, U+ ^5 G+ F# o { - return renderLayer;+ `7 {0 ~$ t* k) Z# r& Y6 b
- }8 N8 {1 V3 a5 e
- }
' D5 T9 w- r: p( x! x - }
复制代码 |
|