|
|
, i+ m* Z/ _; x- l行,这个怎么样5 a2 ^4 z" M2 Q8 ^; T1 W* _6 z
- package com.xhg78999.mtrfac.render;' J8 H5 I. d9 |2 R
- 4 V6 T2 K I- \$ r2 n
- import com.mojang.blaze3d.vertex.PoseStack;2 r; Z$ n- D+ U/ {% ^9 ^& A
- import com.mojang.blaze3d.vertex.VertexConsumer;6 H, F! L: S. ?4 u7 e n7 u
- import net.minecraft.client.renderer.RenderType;
e% A- G( F- F7 g! n$ x# a - import net.minecraft.resources.ResourceLocation;4 c3 ?* t6 D& c
- + A) b* A! U' L% |- {, U8 [
- import java.util.*;" u9 [2 Z& F0 P/ S$ H; G3 R$ F3 ]
- # M# l6 k+ k6 k8 _! y: g' U
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
9 |2 W# T, M, p& l, R W7 { - # F1 ?$ J& C4 ? Z. t
- public class LineRender{" C: y7 |. m( V7 R5 P, J z
- private final PoseStack pose;
: o+ k% ]9 M* E. M. O0 q. i - private final MultiBufferSource source;
6 N5 _# B+ z% G - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
" U( A" }4 x" @. _" [+ m9 B9 \ - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();3 n! m2 I9 l& o# D
M4 h7 [; U4 s# t2 F- 2 H' x0 x7 L) N; x) M+ k
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
' ]# Z0 W: @* J9 y1 g) O - if(x1 == x2 && y1 == y2 && z1 == z2){& w" z+ g+ l! J+ k
- return;4 P/ A# @! o8 W# T: h) c2 b- A
- }
- G+ M; M8 \$ l9 U: E. ] - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
3 E2 _5 z- p; d `8 l( I/ M2 \ - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
2 y2 k) z5 C$ N R: E - }
$ W: }! W: {! H: f$ b! G - pose.pushPose();( {4 @' r8 u! r1 L
- final int newLight = convertLight(6);
- E. L/ n# l3 n; ~' F - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));; K4 b* B/ A% h. o# A
- final float lineHeightSmall = (y2 - y1);9 F# ^0 N$ |" a& v9 y$ P+ w: o( w' T
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);6 r: y$ O) g; L- O, I9 L* t: z7 ]% `7 z
- pose.popPose();/ R: T, S2 w& q, @) E* y
- }+ b- T( Y0 z S$ R& D; I( ~% \
- - k/ a+ E6 h& R. B! Q8 |- K
- private RenderType getLayers(String texture, int light) {1 S. Z7 _0 o7 r( _) Z6 K5 x# t! @4 b
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));6 n8 f' q" A# V/ B6 G- p) G
- }8 K2 z- W1 S; t) y
- 0 k+ n5 z' G% U3 D% n
- private RenderType getLightTexture(ResourceLocation texture) {
% y: F y8 Z1 t/ e$ B+ [% B - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
( w% y& ^8 T& p# u! [9 r - }
; p w; g d ]) z- S
$ j. J9 i8 [% x- w- private RenderType getTexture(ResourceLocation texture) { d) e$ Y* L& ]8 ?: e
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
# R4 f Z8 T+ I; {/ R" { - }
" S+ b. ~* u- s6 K( g - 6 V0 Y* ]7 u( v
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {" p( X0 E+ E0 p
- if (cache.containsKey(identifier)) {
8 O7 W1 ?; b, c+ S8 H N - return cache.get(identifier);
3 K; `; u0 q6 h2 n, d6 b$ S6 @ - } else {$ `' N: K" S$ _' I! X$ n9 E
- final RenderType renderLayer = supplier.get();
9 q1 e' }; |8 F* n2 Z9 Y - cache.put(identifier, renderLayer);
- Z# u! j. h. L - return renderLayer;
3 Q# [/ J! A' D, ^( \/ J3 S$ e - }2 M& x7 V! k4 h- |
- }
* s: B2 A J$ | - }
复制代码 |
|