|
|
$ z+ W5 J. ^/ u5 j0 @5 T7 M' x, A, V
行,这个怎么样 ]3 b5 M- l3 w( {' `, P
- package com.xhg78999.mtrfac.render;
8 f4 o, R. k9 F ?( C* B
8 v6 |0 g1 v/ v5 u; T- import com.mojang.blaze3d.vertex.PoseStack;
" o3 M5 M3 F- ?1 N6 {# E( ~# j - import com.mojang.blaze3d.vertex.VertexConsumer;0 A$ x$ ~0 R: C" r
- import net.minecraft.client.renderer.RenderType;) F: L2 m) I1 r0 l. b8 d4 v8 H
- import net.minecraft.resources.ResourceLocation;8 Q/ ~7 N! s% Z1 M" B1 R; C5 I
- 1 J$ _7 Y( ^' Z& M' o
- import java.util.*;
- m. D2 N2 L3 E
4 T* u3 C* L$ ?3 Z! t- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(+ b6 J m* g7 O+ N; g8 J
- & l7 t1 O% ~0 z5 w; Q
- public class LineRender{- Z1 I" V' U {8 [4 Q& \
- private final PoseStack pose;
5 [& T- A9 e8 N8 [ - private final MultiBufferSource source;( L4 y; e! D$ v1 t! ?1 B" q( I# l
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
& G" o4 D% b" j - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
+ R' \% Y. B8 z! u
1 d$ l2 Q' h0 {/ J3 o3 u. A9 h, k
2 B1 L" l! R* i- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){8 d O. D0 S) K' U9 V9 L6 S
- if(x1 == x2 && y1 == y2 && z1 == z2){
* S0 T2 }0 y+ n2 u" Z1 u3 T0 u - return;! N) U- Y$ S. ~
- }
0 w7 C" A' d) j" w, k - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){" ^2 v& J( q, P1 w) Q! s: x
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");" T& z/ I* Z+ }/ ]$ L
- }
1 Z; e8 M" d5 b, M6 u9 c* _ - pose.pushPose();) {& A9 c: h4 f6 g& P, K$ w% _
- final int newLight = convertLight(6);
8 ?& P. X y( I8 g7 x - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
+ J! C0 g) z5 Y5 m- u' s7 q - final float lineHeightSmall = (y2 - y1);) d/ `/ Q$ a: [1 `' K2 m
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);% |% D/ c5 ^- ~1 R9 p/ H0 g1 V
- pose.popPose();
# ^% T) v0 B$ d7 }: s - }& K% V( V9 _2 n
3 U( h. d8 N4 ^6 M6 G- private RenderType getLayers(String texture, int light) {& M" R0 w) {8 B5 H. y2 }3 ]2 o
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
3 S! _4 S( D- k) e# P; y& o - }
+ t0 { F1 D# m/ B- n* v - ; m4 [: g! k) D9 I) m& v2 g' n+ R
- private RenderType getLightTexture(ResourceLocation texture) {
( Q4 E/ ?, h. r2 { - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);" a' x: @, B( ^1 u3 K7 K
- }3 u% N/ d1 ]8 h' m7 i) G" E$ G
- ' q) a) u% h; y5 k
- private RenderType getTexture(ResourceLocation texture) {
- ^9 o* T u8 a5 b& m2 O - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
4 [) R8 I$ `( C9 i9 V& ]" @ - }' y( W1 m) A' ^2 k1 k
/ k; Z1 O! j o" H! `- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
0 ~0 x) w/ [+ b( G' {( ~ - if (cache.containsKey(identifier)) {
- }+ Y1 p8 Q0 O) w+ a. B - return cache.get(identifier);3 F! X3 K- q0 K+ n$ Z. l
- } else {
2 g$ f1 C( q+ l7 ` t - final RenderType renderLayer = supplier.get();
) [' E: A5 i3 H% x e - cache.put(identifier, renderLayer);
) {% X0 O- }: Q - return renderLayer;3 S2 \. L x! D: w
- }: X1 x& g( E1 ^
- }: r* ?9 `3 f0 F
- }
复制代码 |
|