|
|
2 M0 J* [8 W$ O, F* ^行,这个怎么样
, H# x0 X& p0 U. z9 r8 u- package com.xhg78999.mtrfac.render;+ V5 A# }; q8 B* \$ Q
- 4 E3 F0 e( i7 B
- import com.mojang.blaze3d.vertex.PoseStack;" I5 Y& s1 \0 f, J! N
- import com.mojang.blaze3d.vertex.VertexConsumer;2 ^- A. ?: ^ H* c8 ]" X
- import net.minecraft.client.renderer.RenderType;, |* X# I# g9 ]: c4 K8 Q
- import net.minecraft.resources.ResourceLocation;
0 W! ^* u# ~( k+ Z! ^
/ v0 @5 M" C$ m! B. x4 ]7 Q4 S- import java.util.*;6 M2 V, y! @3 v c7 [
3 L8 _( W3 ]8 x- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
; C- d3 C ]0 i% m& w - " D$ n0 ^- z" g5 Q+ k1 \$ l5 ~
- public class LineRender{
' s; g3 b: |) C4 r. q$ q7 y - private final PoseStack pose;6 u/ i- R% ] A
- private final MultiBufferSource source;; ]* p% G c0 l0 y
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
4 f* v7 E: ]' s7 r: R - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
" @+ r% f' Y+ P; P6 Q - 2 p4 n H' C" ]% W4 p
5 h$ i7 O7 z- J2 F' L- i- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){. Q7 x) R" z9 [! u0 t
- if(x1 == x2 && y1 == y2 && z1 == z2){
6 c' M( Y+ @' z; G - return;
! Y8 N* r6 R( s* D - }
$ f, t+ b9 h* } - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
5 h/ I8 c4 w, l [9 F - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
[# q* z- K: z: ] - }
) a8 h4 g" d- y3 p2 A+ C: g: e - pose.pushPose();
4 ?3 q5 y# d# Y* R/ f( i - final int newLight = convertLight(6);
5 P: n+ F4 P& B6 @+ k - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));6 D* z$ C, g. X& p6 @
- final float lineHeightSmall = (y2 - y1);
o8 B* a1 _" _4 @ - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);6 g3 j0 J" R/ [, i8 y# S% y4 ^
- pose.popPose(); N7 W+ p8 D- J5 C% ~3 ?, V
- }9 n2 o) D* j c
5 D! u+ S3 F) s3 [2 z- private RenderType getLayers(String texture, int light) {' h/ f; }; l! T( l! {8 R! A
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
# w! C5 q5 J; C4 u; a - }
/ x' k- x/ }- c. n+ m
) O9 |- K) B0 n" Z- private RenderType getLightTexture(ResourceLocation texture) {
6 k& D7 S- [/ ~/ n) ?6 ] - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
( }# z/ H1 E3 W - }
- J X, s/ V( w u( k, D; d
. Y2 o( X; k5 o( n/ L& l- private RenderType getTexture(ResourceLocation texture) {: S' F& A$ g# u- @% @3 ?$ Q
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);3 j" U# c" k# F
- }
( |& L+ X* {$ `! | - ]) r) h9 D$ Y% B# ?* o4 I9 R
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
6 o9 D3 _; I1 U; b! z0 q - if (cache.containsKey(identifier)) {
. w# l- _7 M J; C - return cache.get(identifier);) q$ N( t y; ?6 ?3 C
- } else {
. o* a6 p3 g" q4 ^ - final RenderType renderLayer = supplier.get();
' B% ^/ q$ w) N B - cache.put(identifier, renderLayer);
8 p) b1 E: Z7 d% e$ X+ h - return renderLayer;
6 m' X. b9 s# |3 B% T - }# H( H1 s7 N' K5 I
- }$ G6 n' E; w1 q
- }
复制代码 |
|