|
|
/ ?1 F+ `1 q( |8 t/ U" `5 K
行,这个怎么样) g; w% z2 }: b# G+ z3 Q/ O0 Q8 [
- package com.xhg78999.mtrfac.render;( c) ^: R& S; \3 g$ ^1 \( K- Y6 y: J
- - p& a2 A6 m, L! P' D9 C7 W& p
- import com.mojang.blaze3d.vertex.PoseStack;+ K) E, s& k4 G2 L1 P1 I
- import com.mojang.blaze3d.vertex.VertexConsumer;
3 D* Z# E R8 u6 ^( Z& { - import net.minecraft.client.renderer.RenderType;4 K; e: k7 v+ |3 I) r5 B5 o5 n z
- import net.minecraft.resources.ResourceLocation;
9 {7 [, ?7 ^* s& N1 X4 Y' d8 S8 J$ B
4 c/ E& e( k: O- import java.util.*;
, d8 L% @0 M* c( e, Y4 W" F- @1 L
% x; n& h! g# w4 i) c$ R: F1 y- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
+ ^: T; C3 a2 L. Q. N! r1 Z - $ v. F6 s/ O1 ?# O% ~
- public class LineRender{( C+ b7 X2 ^4 u' ^8 K! w0 C
- private final PoseStack pose;
; Q0 ]# c) b/ O) s - private final MultiBufferSource source;8 Q7 D8 [* S# D3 D
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
0 K! T/ F/ Q" p; u, [ - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();2 O. H) K+ { C# p9 [
k' ^. H# b, }; e- & h0 R* _( u$ V5 T
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){# S* G% }2 n* j1 N1 B; v9 a
- if(x1 == x2 && y1 == y2 && z1 == z2){! _+ Q0 L% G- p9 f$ A8 U
- return;7 O3 O- T, E8 L. l; r9 D& e# |
- }5 |- ^$ n0 F' i% p: T: v; i- g
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
! H- U& c8 t1 }1 M; V2 Q - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");& H" F- U7 e, `" q" B5 H
- }
1 g2 a7 W; ]/ }4 U - pose.pushPose();
- X3 f) ^8 e0 f; a/ p$ W( e - final int newLight = convertLight(6);
0 i/ v2 v* c& D) k; [ - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
3 q4 \0 C; ?/ B1 D - final float lineHeightSmall = (y2 - y1);+ g U8 ~- B) S" \ w& m) B- n
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);, X$ n6 z+ ]7 C/ j3 @+ V; d6 p
- pose.popPose();
, ^" |% ] @' y2 w- V0 K/ w/ n$ D - }( X/ \' v4 ^; H1 }7 X* z
. z- B% y5 d+ H6 o- private RenderType getLayers(String texture, int light) {
7 D: f' X2 G: R5 w1 [* P6 S - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));8 N ]- \2 ~* N" u4 ]
- }: ~) [8 Q. H. J/ K$ r- z P2 ?
/ D/ M% `# N6 `& Y8 y! @1 e' `- private RenderType getLightTexture(ResourceLocation texture) {
z) r- ?% @8 W& a* S0 i8 c. g* A - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
/ v) P+ t; k' P5 S* h% T, Y# m - }% w+ g4 f$ b! Q \
- $ g9 {: B- t1 g& W% x
- private RenderType getTexture(ResourceLocation texture) {3 q0 V+ C0 U [
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);4 Z9 ^3 d3 x, J/ X" S/ D
- }
* D }+ V7 l* } - 9 g5 R2 V+ V" a) S0 C. ]
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
2 M9 Q( ^1 v& e q V, P0 [ - if (cache.containsKey(identifier)) {
& m( [4 P. K7 k1 M6 o - return cache.get(identifier);
3 F5 k6 i: Y& j( e. {5 W8 y: u$ H - } else {
% M& f% N" i8 l( e" b - final RenderType renderLayer = supplier.get();
& @+ n0 G0 J4 W8 G, A$ H+ i1 P& u - cache.put(identifier, renderLayer);
7 v- Z+ r- |& T: a$ h1 y# c, e - return renderLayer;
2 f8 L% I' M) n- A& H1 X9 I - }
$ ?0 O, Q5 }, C5 Z' a7 z - }
+ f4 ]4 _+ y: t - }
复制代码 |
|