|
|
. b* C9 p6 w L. r行,这个怎么样 b/ W8 {: }% z" N
- package com.xhg78999.mtrfac.render;
4 `1 }3 W5 J j6 ]. R: M& E - , c! H* `, Q- A' l( ~6 g/ f! T) l& d
- import com.mojang.blaze3d.vertex.PoseStack;
0 h! K9 C, K R. { - import com.mojang.blaze3d.vertex.VertexConsumer;
$ I7 L3 W9 L3 w. J - import net.minecraft.client.renderer.RenderType;
4 o- u4 `: l0 h0 F7 Y - import net.minecraft.resources.ResourceLocation;# i% G4 w* I+ Q, |7 }1 ~ O6 @
- ( z* }5 N5 u. `3 ~" G% B
- import java.util.*;
* K* g% V: ^: w. N+ z% B
+ E5 m: ], N3 N+ B) I, M- [- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(( m" \6 m7 J/ `
4 h$ e" a+ U- A7 N- public class LineRender{
2 C3 _$ l0 o: j+ X3 C/ B( M5 Z/ } - private final PoseStack pose;
6 x+ P4 Q. \# l. \4 b+ f - private final MultiBufferSource source;' h( Q; s B# b2 w/ P6 D8 V! T
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
" D8 z! P. t7 R$ r' d - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();& e D! Q/ q& \# k5 z# ~
5 I4 w2 i* P1 F4 \/ H6 R
* s# }3 X$ N/ E/ j- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
7 F) H% X( S9 G6 P( _' _ - if(x1 == x2 && y1 == y2 && z1 == z2){. @; [; \- a: S. G
- return;$ g" M6 l2 e, L2 K
- }0 \# e" v6 w7 I* E4 d
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){; ~% [, B$ M* v* q. H
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
# D# z1 i) ^0 b5 a - }
# P! [% X( K2 V$ c - pose.pushPose();) Y5 }0 l t: ^" u0 p# I# t
- final int newLight = convertLight(6);
+ v, \* f8 U# z% r& Y - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));' p Y- c7 |+ l5 X" X% q& T7 m
- final float lineHeightSmall = (y2 - y1);$ v. w) _; }" g3 U
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);: e/ k1 N. M0 O7 Y: W
- pose.popPose();* ^. {& x5 e& _6 ^
- }* y4 A* r/ O( b8 c5 Q& c* D% \
' ?7 t7 k( l n( p) a- private RenderType getLayers(String texture, int light) {" s* e9 q, K" k3 c$ |8 f
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));. K: W0 g7 {, E' ?: s7 q
- }# S6 S+ w6 D/ \0 w4 ^8 g, n
- , B% M6 K+ S" Y% K+ I7 E9 r
- private RenderType getLightTexture(ResourceLocation texture) {( x1 g5 V) H, ]% P; I& N
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
. F9 g: B3 r- w# s - }/ e2 P8 h. [! S, g) n2 i
3 {" @- m3 Q0 `8 e+ X- private RenderType getTexture(ResourceLocation texture) {$ M/ b! Q7 A5 S( I7 U
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);3 w& ^3 a- R+ W1 x
- }
3 j8 L5 X* c' L$ o- `* H( J2 \# Y
; J1 ?2 r1 A, P) {- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {* p6 H, l5 l; H3 v1 e f
- if (cache.containsKey(identifier)) {3 ? _& Y% L( ?$ Q
- return cache.get(identifier);
3 L6 u- b6 I) Y2 S. i- G - } else {4 x3 t* A- v7 ]0 s; o* W; N! |* L/ D
- final RenderType renderLayer = supplier.get();
: M* p" y/ z( v4 h - cache.put(identifier, renderLayer);
0 H+ d9 T/ G" I4 M8 [, M - return renderLayer;
: E: p: U) A) o+ E8 f# b - }
" h+ e3 z+ A1 c6 {6 Z: B - }& e$ h$ c' P' Z" m/ |1 g
- }
复制代码 |
|