|
|
6 L# S' a7 j; [, z! c% v
行,这个怎么样
5 q7 s" d$ L h- package com.xhg78999.mtrfac.render;# c# E+ C' J* z/ j
- 3 j0 l& O' ?/ |! J2 |
- import com.mojang.blaze3d.vertex.PoseStack;6 c; b2 x8 D2 z3 f
- import com.mojang.blaze3d.vertex.VertexConsumer;
% ~3 [) C$ ^0 X8 | - import net.minecraft.client.renderer.RenderType;, U& \* J6 g, p8 A3 d, i
- import net.minecraft.resources.ResourceLocation;
. M) g3 p& y+ @3 `# C1 y$ ]. H
3 Q$ q n" N# O1 D: J0 }- import java.util.*;" z0 W7 Y8 t+ K! P- ?: N. w9 m% K5 e
- % }. |) N, g) ]' B* Q8 ?/ ~
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
' Q! E" f. g5 ^8 N6 ~ B7 g: \
& z, E2 _. @ o) c# `$ Q- v* m- public class LineRender{5 w/ s3 V. O2 A4 q7 ^* [
- private final PoseStack pose;
( ~; m2 W! H4 L! Z - private final MultiBufferSource source;' q% m2 g+ u: ]* |
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();# R3 v, U7 z- G" l B5 e0 w" D& ^
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
5 m) n/ ~7 }5 ~: X2 y: v% z
- X( f$ c$ a6 ] y9 e& G
$ G. U; n) g# {; y. H, W7 A# w, x2 k- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
+ K N3 D; _; x3 ]4 y4 ? - if(x1 == x2 && y1 == y2 && z1 == z2){* D5 g. V! Q, a) y
- return;* O, [* ?. C k, s$ f0 }0 U- x* ]
- }# x4 c5 G5 m' ?1 A# ? {
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){) j2 v- c- K3 d
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
' d: d0 ^% I+ _% q$ i- R1 e5 z - }3 L8 N! m; O4 O) h; W' A6 p4 d
- pose.pushPose();
2 M, J! f5 _) m% Y0 A8 Y - final int newLight = convertLight(6);3 I+ q" s" L1 K1 N6 ?
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));: f- I* Q9 q- a5 E. K. o
- final float lineHeightSmall = (y2 - y1);2 ^! O: J* A, P8 K4 n
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);% Y1 D8 J6 C# `# n3 d1 M* n
- pose.popPose();) u+ D1 E8 E7 q
- }
) r# G( s2 E) N/ a7 m7 m5 H8 T - + f6 h: o+ s. T+ M4 e. w6 [
- private RenderType getLayers(String texture, int light) {
/ k' g; f7 }+ n/ t; g) h - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
- f. f' i1 X3 f6 {# \1 m - }
" L3 P* X8 P2 @- X ~* P3 U4 ]
2 D% I& p5 e6 p1 [8 i- \( @6 [" ?- private RenderType getLightTexture(ResourceLocation texture) {
8 C2 l$ R# ~) b: z/ _) B - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);# t! |7 i1 o/ {; i
- }: M. |* m+ y" E- L* a& f8 }. \2 G
- $ X) N1 G8 ~8 V2 u2 \# b2 F; U
- private RenderType getTexture(ResourceLocation texture) {
- g3 s& n, I# R+ ^5 V$ ^& | - return this.cache(texture, () -> entityCutout(texture), CACHE_B);" h6 r$ a3 a# L$ ^4 l3 E
- }
2 ?9 j2 w4 \3 Q0 W0 G7 O$ Z/ h0 a
, x4 d ]/ Q9 ?' G0 L. m- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
6 Z. M4 h* A) K - if (cache.containsKey(identifier)) {3 }1 ?; D0 N; T
- return cache.get(identifier);
% `/ J0 z& Z7 B - } else {0 q3 ~& ?0 w7 W- P- m* u
- final RenderType renderLayer = supplier.get();
( {' w0 c; h1 B: F. x - cache.put(identifier, renderLayer);
+ _0 w/ K) P6 U9 W) P - return renderLayer;
% R8 o5 |) h7 i - }
$ d, O9 E, E6 I! I( {* G5 k0 T - }" p# J. V6 M1 T: i
- }
复制代码 |
|