|
|
1 y2 v) ?/ I u
行,这个怎么样- B2 o+ U1 G& s- H: A& W
- package com.xhg78999.mtrfac.render;9 G# u# S$ L) W& v+ x
9 C6 m B" [& N. k4 b- import com.mojang.blaze3d.vertex.PoseStack;3 k5 n: |5 Y5 B' T) T( g" c2 l
- import com.mojang.blaze3d.vertex.VertexConsumer;
/ u& \4 t: e, i1 L - import net.minecraft.client.renderer.RenderType;
# M g+ G! h- L6 \* a. T. i - import net.minecraft.resources.ResourceLocation;
& y# ?( s* r" B9 ]+ {$ I' G - 9 L& [! M5 F- P. S/ z, e6 M8 Y& q
- import java.util.*;6 v# t6 e' \: |0 Z
3 ? I9 r& C$ n, Z6 K5 k- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(; i2 [+ v' p* s% I( `
- r O$ F+ `3 S6 c
- public class LineRender{% o8 d( V. w0 R, |0 i
- private final PoseStack pose;1 H) C y+ l0 a# W7 r6 X: K* H
- private final MultiBufferSource source;
5 T3 n1 o9 }, `' _, m1 w. t - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
1 u0 h( a9 ?. y6 O( L& c; f( p - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
$ F# P& q# N c @7 k
0 @; A4 Y# N( V- q+ s& r& |! f
/ B7 ]$ J2 k, ]6 H1 f4 J9 W1 W# ]- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){6 S& T3 J. a5 K; x- e
- if(x1 == x2 && y1 == y2 && z1 == z2){. m9 q. u2 `( J7 `# v
- return;" G% U( M6 X& X0 U# W% [4 {
- }/ t2 w: w4 ~+ ?0 {
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
; b3 T% a, @" d - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");$ b# X( H6 X R
- }9 E# c7 c& e) H/ \
- pose.pushPose();( u4 ]/ R7 ~! ~- S7 z: @7 l
- final int newLight = convertLight(6);
$ c r. I3 L# D U; T$ O - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
_' ?+ ?9 m+ Q( g2 N - final float lineHeightSmall = (y2 - y1);' i- @1 H8 ]; y9 V) ]
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
3 P/ B* W6 q) I3 W - pose.popPose();' C) I* }- n: v2 i. \; |: E3 [
- }& Z! A* j6 u# \
- / w) m3 j- z$ O/ a8 j
- private RenderType getLayers(String texture, int light) {% F& k' `6 {0 n
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
5 y/ t$ \: }% o* g- ?( \6 T% T - }
2 q N" ]% @& I - ' r W9 {) D/ N
- private RenderType getLightTexture(ResourceLocation texture) {8 h1 _7 t( k1 l1 y7 f
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
; C3 Q0 ^. ^# J2 [; V - }
/ v& d+ ]2 s' V C0 ~. Z - ' A5 X! W6 k% B I3 S- q
- private RenderType getTexture(ResourceLocation texture) {# q9 d7 N1 z" c6 F' h; I5 T% y0 b
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
% Q. O$ C- @' G& J! S4 ^% e e - }
. G, r! C4 ?1 {. j$ [/ n+ z& x5 X
/ Z4 M3 ?' u) w- L* y- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {1 c9 M" I. J2 ]: e/ X% E
- if (cache.containsKey(identifier)) {
9 T4 b+ \9 O8 _ a% T8 w _ - return cache.get(identifier);
1 h* E( J5 Z/ E _ - } else {
4 D3 }, a0 [: ?- { - final RenderType renderLayer = supplier.get();: }5 U9 c' F8 P/ Q, p
- cache.put(identifier, renderLayer);
6 @. c- O4 E4 z+ T* m/ q0 r - return renderLayer;6 P- `+ J$ f7 U. V; e R4 u: s& D
- }
; f7 @* E' f+ Q0 I& [/ Z& b7 r - } W" x$ f! z( \; J% ^. X/ C
- }
复制代码 |
|