|
|
% @, t' w+ v; F E3 ^6 e( S+ e- F行,这个怎么样
. P: G8 G: z( ]2 m$ k4 c- package com.xhg78999.mtrfac.render;
7 m: Q- m4 X! s2 f/ y, w$ Q4 g
5 J0 Z0 G, o: L( V/ i# v- d- import com.mojang.blaze3d.vertex.PoseStack;
y* }9 b D8 Z+ ?* T - import com.mojang.blaze3d.vertex.VertexConsumer;
~5 ]) L, _+ n4 X' Z5 h7 ] - import net.minecraft.client.renderer.RenderType;8 R# C& k& ]' p7 }) s `+ t/ N: i
- import net.minecraft.resources.ResourceLocation;4 _( j, s: r- p# I% o
& W" Q% _2 M, N: e- import java.util.*;% D1 V+ z% s$ y& S# ^+ S7 D, | S
; a; b* g* K' z# z- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
j4 t7 C8 [' J6 [; C( H# n8 M - - a! Q4 n1 A% J) P2 A7 _
- public class LineRender{/ d0 ~- h) H& T
- private final PoseStack pose;9 ~4 q: H9 S1 m- ^
- private final MultiBufferSource source;
6 ~: m3 @8 V0 d0 a1 h% S - private static final Map<String, RenderType> CACHE_A = new HashMap<>();( s7 c; ?! `3 Z. Z' |
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();' g+ O) f$ G% y5 S& L' `4 f
6 H; w9 K$ f% t- : ?$ e$ A2 k" j: ?* x& a( u* N+ h
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){/ O1 X/ o7 |/ K% g
- if(x1 == x2 && y1 == y2 && z1 == z2){
7 t" g* Q; u3 n/ F: A4 x# W. t& t - return;
( a& b/ a* Q3 c! C: V9 w - }; V) v( l5 B" O4 f$ C) m: R* ?8 L
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
" w7 w; ?4 _7 F- A. g% ^ - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");) F# T, S6 }, G8 E( z
- }! L: E8 O# Y+ z7 l* }" w7 V% S. P
- pose.pushPose();
, E6 |" Z+ v2 }- X5 K' b D - final int newLight = convertLight(6);, A/ z' c4 s" B# ~
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
' R k9 Z6 p$ y; j2 \ - final float lineHeightSmall = (y2 - y1);. Y: Q3 U3 e1 S# I' x
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);8 d3 y. @# T2 ]( G; P" Z2 P
- pose.popPose();
' c) L) W9 k! [* n9 [+ c7 h - }
8 O3 h/ _1 |2 C; ] - # d% T1 c h$ E. F' N( N% P# M
- private RenderType getLayers(String texture, int light) {0 |/ { S$ `1 J$ _5 A% _
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));6 n+ @+ H& _% D' I2 k
- }
4 p; I+ g) I1 z - 8 y7 x( U5 K9 G/ t: j1 K
- private RenderType getLightTexture(ResourceLocation texture) {* N# ?+ X; V( }7 P
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
0 |) D5 Y# I5 { - }$ g& M: K$ a1 a) L
- 4 ~& q3 o3 L1 v6 w3 s: ]
- private RenderType getTexture(ResourceLocation texture) {2 x y' ?9 m* l; n. W3 t' {6 |$ O
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
+ u* Y/ L6 Y+ s. u. y2 j& Q - }
0 |6 d5 y$ }; ^' E: @* f: I - 3 p) f [. _& \$ l a
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {3 k( T1 \9 V! [: W5 V
- if (cache.containsKey(identifier)) {
3 T' k* J; c& i1 g. \! n; F - return cache.get(identifier);
( e ?- n& w6 S6 W/ j+ m - } else {
# @; W& \, D( S8 s1 O0 a - final RenderType renderLayer = supplier.get();
' }. S* }1 Z7 ^# ^; E9 h - cache.put(identifier, renderLayer);
, E6 N( l4 K# i9 q - return renderLayer;; O7 U2 m* y& I$ E8 ]
- }+ M) A: A! p6 q
- }: ~; c. u. ?. S* G
- }
复制代码 |
|