|
, H7 b4 b$ G* P- w/ M3 [1 j
行,这个怎么样2 r: w7 d3 c& n0 B, r3 ^3 n
- package com.xhg78999.mtrfac.render;: P( o6 O8 c1 A w5 l
- ! k. z' }& X5 D+ ?8 A
- import com.mojang.blaze3d.vertex.PoseStack;
/ ]4 z; W8 f R. J - import com.mojang.blaze3d.vertex.VertexConsumer;1 H+ w8 C) _% [9 h7 R
- import net.minecraft.client.renderer.RenderType;
: i) F" t# _9 M* r4 a - import net.minecraft.resources.ResourceLocation;+ c, m5 g, w7 @) ?4 o+ B, R: _6 m
- 8 c: i. l$ v5 @7 O
- import java.util.*;/ D4 f8 |+ D! I' W7 e5 Z! o+ A
4 q0 A6 a% X( G8 K' C+ W' ^- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(( D* Z' r# M% u5 h
4 E+ B$ ^! O# V6 k5 ?# R- public class LineRender{4 F0 u6 f. D. \' t" T
- private final PoseStack pose;
4 D9 n# h3 [) r2 N - private final MultiBufferSource source;! B _1 K ]2 I
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();4 ~! ^+ Z0 k' P7 Y1 V
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();8 `% e0 M) Z% t- V+ j$ c% a" o
- 2 U; o- c% q1 J! x
- 7 ?/ T) d# P8 X
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){5 q X V+ K* F6 R) o* a$ A
- if(x1 == x2 && y1 == y2 && z1 == z2){2 _6 d% Q; m/ K1 q2 |8 |! `" m
- return;
$ N5 G0 A; _! A - }
- \* ~! g0 E* V/ D( ` - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
6 J+ {8 d& P0 d4 ^- t( o1 u - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
# ?; e5 _* g1 y - }/ j5 ~" V: q- @# t
- pose.pushPose();
0 Y2 C; @+ s. e$ n k2 n) d - final int newLight = convertLight(6);6 r) Z" N& y! d7 ^) A) r) D
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));# e$ f+ y S; k- Z
- final float lineHeightSmall = (y2 - y1);- _* H6 {6 }* j
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);9 D' r5 `# q/ Q# p9 V) v
- pose.popPose();
/ o' F( _- Y5 r - }' h5 a" ?9 F" c4 v
- 8 Q( {9 h) Y6 S( X' B
- private RenderType getLayers(String texture, int light) {; U3 a* _; j$ p# U) }
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
& Q1 {" k+ Y, T, R% X& I2 X3 z - }
7 @) w6 U* {! M5 }- x0 {" n4 ], v- V - : i9 a5 W. ]. Z9 w0 u
- private RenderType getLightTexture(ResourceLocation texture) { p2 d/ q8 p+ \5 u" t1 S
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);: `6 h" [' N/ o% ?
- }
+ u4 L3 F: Q$ g8 Q - * C4 b" A' b# x4 Y% }
- private RenderType getTexture(ResourceLocation texture) {3 v+ w9 h) i: {' r' ~4 ]8 u) o k
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);! S- i' j5 i- k3 u
- }" l' l( j3 ?8 W+ g
7 U' Q- n a! b- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
+ V/ Q+ s7 T f! g9 W - if (cache.containsKey(identifier)) {4 G0 q2 K/ e8 |6 v2 p# I) i; K
- return cache.get(identifier);
) u3 m b2 l' v4 U) x - } else {
6 k" U. O3 g! C, f) h% x - final RenderType renderLayer = supplier.get();" W& R, b$ n0 f0 A
- cache.put(identifier, renderLayer);; \8 z1 O" ~! I; s/ Z# F+ U
- return renderLayer;# y+ u) e8 Z6 U4 }, U* T% X
- }/ }1 b1 w; M6 `8 g% n' n% c
- }0 e' C3 ?$ c# Z2 P* B6 f+ H! R0 v
- }
复制代码 |
|