|
|
' q8 G6 T2 p0 v' y' _0 o0 ~9 v: h
行,这个怎么样7 `; |- D% I* k b2 ]/ K9 T
- package com.xhg78999.mtrfac.render;
7 E( f# F9 k8 z# Y O ] - / B7 m) x% \! A2 }) `. U; d! A
- import com.mojang.blaze3d.vertex.PoseStack;
/ K* A( {, f1 m- w - import com.mojang.blaze3d.vertex.VertexConsumer;
+ t$ n# [* [) B1 [ - import net.minecraft.client.renderer.RenderType;5 n# I' n0 F: A9 W+ E
- import net.minecraft.resources.ResourceLocation;/ f: Z0 F! r6 E$ K5 s
3 g1 \" T5 W' l2 `; _4 h4 N- import java.util.*;
) G& O- U4 y& ]6 O7 m6 d% u0 l- p' S+ F - w2 n" y) Z8 U& Q6 B' y3 M
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(: g( N) z6 P! {$ Q
2 y0 ^, w" p3 Z. A- public class LineRender{
4 c( D' p) {8 X1 K3 ~/ l - private final PoseStack pose;) J4 y( I2 z( w, p; a
- private final MultiBufferSource source;0 g$ l$ K- t; w- |% k9 [) h: a
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();* A6 `! J3 |' p9 u
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
& C$ y) T1 _/ R& ]5 @
2 s8 J8 @! q. e8 k4 ^, U
6 a q/ z# _- e) e- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){& ^3 i; p* K: _) o' s3 }5 F9 b
- if(x1 == x2 && y1 == y2 && z1 == z2){4 ~1 f7 G# K% s
- return;* M2 J$ w7 |7 |
- }
9 n2 N R1 i) H, c* Z, L5 Y - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
7 J, \9 n8 }$ L0 d* O% | - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
/ g. I0 [) c$ l: Y7 U; x6 l - }7 B- U/ m+ x3 b# y8 i
- pose.pushPose();
( q) f0 U( {# j% i - final int newLight = convertLight(6);6 X: V, X+ \. ^( S
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
; A' g/ i V, |% H - final float lineHeightSmall = (y2 - y1);
' [1 U+ e; o+ T6 I$ e9 U2 i2 ? - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);8 S$ c, Y8 c7 ?$ Y$ y$ U6 p6 [6 t- a
- pose.popPose();4 N0 p z5 i1 `/ }/ |
- }
7 E( ]3 ^4 | e8 o7 b: l7 G+ l - . Q+ d C; x6 d& J0 Q3 ~
- private RenderType getLayers(String texture, int light) {
. |1 R9 Q# Y9 T. r - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));- g* z% `% g6 O6 @; X
- }
G: m* D+ p) V5 H) ]. }6 H - / R9 S9 R) n+ W
- private RenderType getLightTexture(ResourceLocation texture) {, @+ b+ B3 T: Q5 R
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
' N+ \4 ?+ ^( t8 w z; R - }
; Y. q0 Z# m- Y
/ w( x6 e3 ?0 o, z% a. E- private RenderType getTexture(ResourceLocation texture) {8 b+ S, d% i% C$ X, s9 r- M) H; A+ p
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
G* ^- r3 E: E9 B1 { - }* X# |- X$ L; V' L4 \# c+ Y2 o# ~6 Z
- 0 J/ r( l# ?+ E C
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
+ p5 r# D3 a/ c* K; k& ` ~8 f, S - if (cache.containsKey(identifier)) {
% O5 a4 L) F) m% @ - return cache.get(identifier);
/ Y8 b$ s, z- r) k - } else {: P6 h+ s5 \& \9 V3 D. l9 [
- final RenderType renderLayer = supplier.get();) F6 H. |3 q3 v3 \8 Y8 h2 @5 W- ~
- cache.put(identifier, renderLayer);3 y+ c j3 @+ L7 S% n$ R: B
- return renderLayer;. U( x8 Z) Q1 c' Z
- }* L$ P$ Q. X1 }! R8 M
- }
+ J: f- H P+ @+ ]4 B% y - }
复制代码 |
|