|
|
" Z2 o& {9 ~' Z行,这个怎么样+ }3 _. N. H) {0 H. z+ a) o$ E
- package com.xhg78999.mtrfac.render;4 e. r$ v$ p: L9 L2 d! a6 a
& `) l/ B' L! I0 ?3 k- import com.mojang.blaze3d.vertex.PoseStack;
0 ^' F$ G0 l8 v P1 V! O - import com.mojang.blaze3d.vertex.VertexConsumer;
~) H+ m: L& { ~) \' o - import net.minecraft.client.renderer.RenderType;0 f" p# P" E: |; r, C! D
- import net.minecraft.resources.ResourceLocation;+ B f: r6 S2 q* s, `$ ]
- ! _% U2 l: q' x4 H! ?* `9 P9 [
- import java.util.*;
. T0 j7 N5 Y: N
/ r* P3 y8 k* a, u- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(6 }# v/ R3 V4 [. v5 u
- 0 m' V. M9 E/ i! X3 Z( x; J
- public class LineRender{: H2 w$ ?& n t: R& Q
- private final PoseStack pose;
) G! A2 {1 l5 @5 k5 h6 | - private final MultiBufferSource source;
3 m" f) l' n8 y p& B4 y - private static final Map<String, RenderType> CACHE_A = new HashMap<>();- |3 z& n/ n1 D! A) l( c, U
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
$ y% o* x- X, Z" z# Y! E( H - % N8 \, X0 \5 y& ]) y, @+ Q
. V2 f" ~- O8 C, ?$ _8 T& S. Q0 U" u- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
, p2 l- Q7 _9 _* f1 S3 E$ w6 ~ - if(x1 == x2 && y1 == y2 && z1 == z2){
' b6 |) r, a/ ^% l - return;
`# {( H0 w q3 s8 O1 w - }
. R$ S* T5 z. D7 Z3 z' _3 P - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
2 t1 ~, g1 K$ z7 E% E - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");) p1 U x2 {/ v% ~2 I8 e5 Y& S
- }& ~4 a% m) F3 r: i! J$ Y- u
- pose.pushPose();
8 `( L& K: [ { - final int newLight = convertLight(6);. m% L$ L7 C; K) e% W
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
. c; Z9 n4 p$ k& a2 Y - final float lineHeightSmall = (y2 - y1);" ]2 D1 x5 e% I$ w
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);# Z5 e) [2 w6 H2 R0 E6 \
- pose.popPose();
t5 L2 W# s# Z5 X; s& j - }
# u. S0 h" D" G# _5 Y
& j' ?5 U: c* z- private RenderType getLayers(String texture, int light) {* I- U3 w5 m( N& M% k$ ?
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));" f; ^. ] [/ Q# H. b0 v
- }* \. p5 g, U) q
- $ ?1 X# U" [6 x; }7 a
- private RenderType getLightTexture(ResourceLocation texture) {
4 |- d# U! S4 R# |( h. M* W - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
+ F& p; v5 u* c. w- X0 i - }& c( Y; T3 g% l! r$ x5 _& X
- 6 ]6 c& r* O1 T8 T/ p; V
- private RenderType getTexture(ResourceLocation texture) {* g8 t6 T v- ~* S& D: @3 u% Z
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);( T0 a# B9 v) [7 u5 v4 d: G0 g& ~
- }5 D" U9 R- w. `) t1 s+ y: M" d: V
- 3 [7 Q8 w0 j( M, I( |; S( W
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {1 ?& C) r1 J3 F* A$ k
- if (cache.containsKey(identifier)) {
: t: K( W. n C; ~ - return cache.get(identifier);
2 u4 @& y( R4 K - } else { K2 |- t$ l, n* v1 J
- final RenderType renderLayer = supplier.get();
5 n7 e* Z! b6 G& J) m3 S) d' g - cache.put(identifier, renderLayer);4 a$ v3 ~0 L* z3 m
- return renderLayer;- [( M) {; }2 e
- }
2 ?% J( A7 L' c - }
/ G; t, J; p6 h - }
复制代码 |
|