|
|
7 \. K7 ]8 ^' t* b行,这个怎么样6 ]! K3 H* G/ @
- package com.xhg78999.mtrfac.render;) o/ w0 X }+ E+ \
0 d/ g$ V% s! \) ]: Z- import com.mojang.blaze3d.vertex.PoseStack;* m6 t$ F9 w3 B; w) L
- import com.mojang.blaze3d.vertex.VertexConsumer;
& ^; C1 ^" |; V$ v- w - import net.minecraft.client.renderer.RenderType;
l0 q5 g) _% b/ y - import net.minecraft.resources.ResourceLocation;
, ^5 _! ~4 R! u1 E& w- C3 N9 q) }4 v - : y/ x5 C9 w' C
- import java.util.*;! p; X. | h% R0 V& L
- - p; r# F% t/ K7 K$ M* B/ a$ k
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :($ z0 r% Z# ]2 ]+ K# q/ @
- 7 b h+ p3 c7 E4 x
- public class LineRender{5 w* Z! G1 y7 p' w
- private final PoseStack pose;& x' F% |& r2 [9 r
- private final MultiBufferSource source; A+ j% I4 S" Z1 t7 r# a
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();6 L2 r3 @( ?9 u0 S7 [7 ^/ x8 S
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
: Y* S: x8 p2 |- k! h5 g# b - ! o0 z% b7 r9 @2 I
: n; @6 C- g+ s- [7 r- Z+ s) ?- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){8 S+ x2 x5 d7 o
- if(x1 == x2 && y1 == y2 && z1 == z2){
" a0 p6 _* P2 D2 a6 F - return;
, ]0 C$ E. l8 _5 Y" b6 ? - }
% V8 U0 i) r+ d) r( Z& {0 c - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){. c5 I1 a( l p+ r% b, U7 g. k
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");9 N# A, h/ G$ R, ^, M' p {; h
- }
0 M! N* q A- t; I* ~ - pose.pushPose();0 H% _+ U$ G4 s9 g- \$ G
- final int newLight = convertLight(6);
" Y) a0 R' T3 l, K9 t9 Z - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));- B4 Q6 H2 B w& `
- final float lineHeightSmall = (y2 - y1);
4 A/ t( M$ K8 ]) o# v - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);4 \! R; y; c' r9 K, R
- pose.popPose();
7 [7 k5 P$ w; j! p - }
. ^1 \4 y* s# D0 {+ E V! W - / x! f$ H7 \8 |. l$ o" u2 j
- private RenderType getLayers(String texture, int light) {
) L! E# y9 X1 E; K7 L - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture)); }1 ^5 z, t* w! k E5 w
- }
6 _; g2 \: n1 @* A. c4 V4 R( `
& |' R. @ W: M7 I/ R8 ]/ t0 e- private RenderType getLightTexture(ResourceLocation texture) {
$ v) y* ?. b1 e+ d- ]# j @ - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);4 s a) J q* O0 X
- }( r- I' w6 w# U$ p" X
- 9 }6 U) o2 M) K4 \* B9 N
- private RenderType getTexture(ResourceLocation texture) {; Q+ ]+ e) c6 z J+ Q7 }
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
( V* P+ F* l4 ?5 A3 j( E - }4 W5 W1 H% }* j2 H$ q
- - G- @6 J, h( y& {3 B; d
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {! K( g8 W$ f2 s: Y! P8 S& w" Z8 e% I- \
- if (cache.containsKey(identifier)) {+ ]% \ M, K2 }* a9 q+ f9 a8 y( Y. \
- return cache.get(identifier);
+ Y" h2 y7 _& U% w& E' L8 o: s - } else {4 n0 v- \5 E9 C. f7 y
- final RenderType renderLayer = supplier.get();
/ o8 n4 e" P$ A - cache.put(identifier, renderLayer);; D& W+ Y$ q n
- return renderLayer;& _; Q6 ?+ N* T; u1 T( y0 }
- }5 j- F7 k' z# V4 x# Y
- }
6 r* |) o9 ^, f m: E# N - }
复制代码 |
|