|
|
% \9 o, u: a# A: H# v$ L
行,这个怎么样3 w y: z5 q4 T* d8 r
- package com.xhg78999.mtrfac.render;9 \+ x4 \( Q* D) K/ K
! |9 a8 x4 ?: q6 @) D( }- import com.mojang.blaze3d.vertex.PoseStack;
* q* g! x2 Y3 |- I+ | - import com.mojang.blaze3d.vertex.VertexConsumer;
" s' i9 B+ F) \: k( q - import net.minecraft.client.renderer.RenderType;8 ]2 a9 I2 f4 M
- import net.minecraft.resources.ResourceLocation;5 f# Z" q( ]) a' V! r
. ]' L7 h4 @6 p, x, G6 G- import java.util.*;
! B9 d5 x2 c2 r0 v+ T4 A( C
" z2 g- @+ q1 N3 E9 l7 G$ y) x: g- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(- s7 E7 o9 p7 C* W9 o* x
- * e+ P; D) n5 t6 m/ `% H, w+ K" p
- public class LineRender{& ~0 X2 n9 W3 k' [ U8 X3 s' J
- private final PoseStack pose;0 O+ h+ b) Y6 j j) W) e u" R6 }
- private final MultiBufferSource source;9 Z& r" t9 w6 s* F. r2 u/ E
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();1 Y: X; J0 r9 f' S% ~
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();( p! m6 O- S7 \' \2 D6 @
3 z* S- f3 M& L. A4 a
% f0 x0 A( }- R2 B d/ F; S! B- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){+ C2 w; _& N8 D1 L( q
- if(x1 == x2 && y1 == y2 && z1 == z2){
) B# m* ]5 e' }9 Q! v; R* h9 q# M - return;" v" s F# ]* z4 ~. l( a6 O
- }
! Q# h% ~3 v$ {4 n% M( C" t - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){( ]. A. B% g8 p+ }
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");) _/ g* E# g' B* Z( O" a" w: F
- }8 Q t* U& ]( G1 x, M% E( j A
- pose.pushPose();: a: g7 C7 F1 w+ e: z1 m% U: W
- final int newLight = convertLight(6);
7 @2 j/ W) r) @6 p2 m; w" y - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
& Q4 q/ Q! L7 a8 m" N. n - final float lineHeightSmall = (y2 - y1);
0 \0 z; m8 |# g - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);6 | d6 f9 ]( v, J) t
- pose.popPose();6 `$ e0 P3 m" `3 U- N% U. A
- }% p5 J9 u3 C+ Y7 ?+ }
3 F. N; d9 l2 p8 p J- private RenderType getLayers(String texture, int light) {
: }, e5 w+ M G - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));$ b& C- v7 L# \: d
- }! ~7 i) J7 c7 p& K8 }% S! J% H
- , U2 g, N2 K9 E# M% L4 l
- private RenderType getLightTexture(ResourceLocation texture) {/ b3 V( c& \( U3 S* q* |
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);' t; Z0 _0 j; d ?+ h4 ?
- }( N7 m+ |0 {4 U0 |( V. e; c
- & n8 T r- y; k, o: F
- private RenderType getTexture(ResourceLocation texture) {
+ S8 L# F/ l* T* C; K8 N2 n, Z X - return this.cache(texture, () -> entityCutout(texture), CACHE_B);7 X& ]& t: R+ v8 a
- }' h0 L& n$ o( z s) x7 f
- ( D0 P3 d' ^7 o; f" V! `
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {- p& X9 m9 v6 x# y, N$ Q* s
- if (cache.containsKey(identifier)) {6 ^7 G) w$ t! p: u7 v( I7 a
- return cache.get(identifier);0 r7 b4 H1 ?# }0 `9 t. A0 ^6 ]
- } else {) {- {2 a e5 W+ S
- final RenderType renderLayer = supplier.get();
1 i' l$ Q$ Y+ {% H7 g - cache.put(identifier, renderLayer);7 U4 w5 y1 w! _6 m" f) m
- return renderLayer;' _1 E }7 C0 x% [
- }+ Y# }6 n$ {8 @) `
- }
! v& }% X+ L( w7 V, w5 y9 q2 c - }
复制代码 |
|