|
|
7 n1 k- D2 G! G行,这个怎么样$ O/ D2 {" ?/ t6 @& E1 ]
- package com.xhg78999.mtrfac.render;
9 k: j. y& C: ~! ^" V
# n, q( a2 ?3 [- n: S- import com.mojang.blaze3d.vertex.PoseStack;8 S5 L% [- Y. U: ^) N) ~
- import com.mojang.blaze3d.vertex.VertexConsumer;
! x5 \( G6 q. S- s" g! P# [3 p - import net.minecraft.client.renderer.RenderType;
* t* E+ L* N7 N, X) h - import net.minecraft.resources.ResourceLocation;# G9 X7 C! T# x! y0 s
% Q8 v* ~% C$ A/ H* C- import java.util.*;6 ]; S7 {/ E" ~
7 m+ B, x0 z. ?- e9 T6 s5 E- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(# T. E* a7 n$ I/ `/ L; o
- + ^+ {4 o* i2 @- {0 K6 `5 Y
- public class LineRender{1 \1 v0 T) w, m
- private final PoseStack pose;
1 D7 w0 N* i& K/ m# l( y4 Z - private final MultiBufferSource source;
1 @3 j: u0 E9 W$ P; J2 ]' O - private static final Map<String, RenderType> CACHE_A = new HashMap<>();# t) u3 X( @) v7 [* q
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();! |- n0 e: P$ ~6 X. j5 f
: u+ {% E: C6 X- 5 X- M# Z: P: o3 k) C1 `
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){* `( p& v+ _+ E3 R% x
- if(x1 == x2 && y1 == y2 && z1 == z2){
$ \% z3 o7 a3 l$ P, t - return;( n+ {0 u4 A! F+ U6 F; Y) i1 l8 n
- }; ?& o& ~7 z Y
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
' [& F# R2 i& R, [/ b% V - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
; ]8 c: @2 ^/ C, l, @ - }" J2 M" L2 r' v! j+ k# ^/ Y* i
- pose.pushPose();& z* R' l* R" _: s: G0 W/ r
- final int newLight = convertLight(6);) U: P" e2 k6 T- \! D% C9 X9 k
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
- Z8 e5 S- m2 } l( ^; a. m# O - final float lineHeightSmall = (y2 - y1);, ^- w$ \, ?5 M: k
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
: o# ] d- A& T4 k5 e# l5 ?' e, t - pose.popPose();. X' j7 @ w0 r. a. u8 `& F
- }
' B. u' q6 L2 q - 4 x# w4 k1 j& D
- private RenderType getLayers(String texture, int light) {
, I: h+ ?: B9 i$ y1 z - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
, e0 H3 y: n3 g0 M+ D5 k4 } - }
2 _0 o6 R; _' e6 }0 ]$ u. @
. l% Z# h2 ]6 y$ l, _- private RenderType getLightTexture(ResourceLocation texture) {( H$ R0 ]6 _* G0 T$ v* }6 `
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);7 R. Y; q* C0 r6 A' ]* L
- }
7 S# j7 T3 y4 j, a& H - ! k- ], X; C2 ?) s5 H$ Y- a( y7 A
- private RenderType getTexture(ResourceLocation texture) {
% X' B( m3 N2 M' q2 {! _; w2 R) m - return this.cache(texture, () -> entityCutout(texture), CACHE_B);$ l* A- t2 }1 w8 p0 {7 F) v e
- }
8 S: D7 v! i( F1 e- Y6 ? - 2 Y2 ^0 m: ]) h
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {( t& s* z( i9 G
- if (cache.containsKey(identifier)) {! t; ^6 k! M0 A8 P& o
- return cache.get(identifier);
: K- a4 K3 G) ~; w9 N+ H - } else {
) Q) { X" _0 i/ o4 A$ S4 X) m - final RenderType renderLayer = supplier.get();
" T" {# p9 F3 o6 j& W4 V, N1 @ - cache.put(identifier, renderLayer);! t6 O, M/ `5 ^. M" i" e
- return renderLayer;7 s' [0 j4 P ?/ u
- }
# I$ v% p# z4 ~0 n _: a - }
& ]" m) Z3 Z1 K - }
复制代码 |
|