|
|
' \: r4 ~5 s, \) z, L/ X行,这个怎么样6 ]0 a& @/ E" M
- package com.xhg78999.mtrfac.render;' c' s, I2 Z. N q
- 0 I: ]% q1 w' @5 ?) f. |' U
- import com.mojang.blaze3d.vertex.PoseStack;1 D# Z' Z* L( v. X. |6 e
- import com.mojang.blaze3d.vertex.VertexConsumer;: q5 B9 W! ]$ p ?
- import net.minecraft.client.renderer.RenderType;
% R Y, ^. j' b9 [. V - import net.minecraft.resources.ResourceLocation;& \- o7 ~0 n4 P
$ Z0 |! C6 r2 N- import java.util.*;
2 x; P3 }" P$ L6 k - # G: L8 p0 H. I) Q% Q4 D; P
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
6 t7 j" ]. r% h' y1 c$ Q: w1 ?* l! q$ U - 6 [0 e P5 j( X- F/ F
- public class LineRender{* f6 V! v8 |- N: p% K* G) m
- private final PoseStack pose;7 q" ?( x& D. W; G
- private final MultiBufferSource source;
7 [- d r, i) A0 e! B1 a - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
3 S5 T' |! g! ]8 i* o* j - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
- _! \& t+ S3 p8 W9 x* c# }
) `1 n- o3 y3 o8 j
5 ~1 n2 M6 B( r4 g$ ?7 u. f5 \- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){& O* _: a& @2 C$ v, O7 U
- if(x1 == x2 && y1 == y2 && z1 == z2){0 k. s+ S, I: i1 [( {
- return;; G- L: ^, E! n0 j/ G; N0 w
- }
) w0 o% B7 K4 Z7 m8 U. f8 u$ [ - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){; F9 N1 \$ \9 R& C# L4 v. L
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
* F- Q3 V: t! n& g$ z - }
" @1 Y- [, w3 M7 p- M8 \ - pose.pushPose();* @/ n( m5 h' m d6 G E( C
- final int newLight = convertLight(6);0 z+ F5 V. ]( @3 e
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
8 S) Y. ?9 R% B2 \ - final float lineHeightSmall = (y2 - y1);. C* Q+ V1 J: R# Z
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
6 Y. x: E2 V* t( d - pose.popPose();3 M! M6 X1 q2 |7 V O$ s
- }
5 z" `2 q3 ]- v$ E/ j8 C
2 }/ G0 C0 }, h3 s# }- private RenderType getLayers(String texture, int light) {
% U6 y ], o# ?0 }9 r, V, q- f - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
+ X( \* V- t: u2 a; C8 _ - }
1 X8 N* j+ u. \ - / L* v( I* B) l
- private RenderType getLightTexture(ResourceLocation texture) {3 {- ]! w& u, \3 H( ~
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);$ _* ?" M6 I" N$ Y9 e- I
- }( z6 }" q4 x7 Y0 a( u" E# s( r4 `0 W
3 p8 g# u" Z" T! g$ N& S- private RenderType getTexture(ResourceLocation texture) {* U8 }8 ?. Y& k
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);9 Q8 O$ n! u5 n* D9 G, e2 O+ J2 W. i4 Y
- }9 r; d& Y9 d, O$ ]0 t: m
- - E" j( Q1 d v5 h _
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {+ A9 W4 t9 Y$ ^. f* f( X5 A& c' _5 U
- if (cache.containsKey(identifier)) {5 n; l! k; r7 ~, W! {
- return cache.get(identifier);+ y& o. h7 K: r
- } else {
% S$ u& |7 e) a8 ?, s5 n - final RenderType renderLayer = supplier.get();
q# r" y4 A2 \1 _ - cache.put(identifier, renderLayer);" ~) J- W, a# K
- return renderLayer;
! ] B2 ^ r9 ? i/ c0 A# D+ ^% ] - }
/ T* O. v* I, ^& f- e! a - }; k* I' Q8 t0 Y3 K# H+ w
- }
复制代码 |
|