|
|
$ {) V9 L2 ~$ c/ r# d
行,这个怎么样
0 @- z" w$ W$ o7 x' U+ K9 ~- package com.xhg78999.mtrfac.render;
' K: a8 v! d* C) w5 ]( B - ) H6 s6 |8 j7 w! ~
- import com.mojang.blaze3d.vertex.PoseStack;5 u9 ~, [: _! z- X2 q
- import com.mojang.blaze3d.vertex.VertexConsumer;
& w1 |' y% y# ]4 p - import net.minecraft.client.renderer.RenderType;
' v; v8 T5 p# }% r( f; V, \ - import net.minecraft.resources.ResourceLocation;
& W# q, ?% }$ s0 V( O, E/ }* i, N
& b& y, e6 H0 R* I6 e- import java.util.*;( @- |/ ~8 U; x6 Y0 G, y ^7 R
4 J! e( w* i: C) g- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
: d, h. G$ d8 U* w# r - 7 H8 b! v" x* N
- public class LineRender{8 Y# [2 X4 d! o T( V
- private final PoseStack pose;
' U" ~- m9 w, I9 X+ Q; y$ j - private final MultiBufferSource source;
2 N9 H* o2 Y A- S/ H! D- I5 H" k - private static final Map<String, RenderType> CACHE_A = new HashMap<>();! y5 p2 q: A! j8 E
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>(); z7 ? j2 g2 |7 i& A8 L
8 G( t& \. J6 ^# m( v& L$ O
( C; E E. \; J2 Q2 p- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
. c% y4 Z" e5 I" W: ^* a6 D - if(x1 == x2 && y1 == y2 && z1 == z2){1 d. c' _, r5 C( ?5 \
- return;
4 p. {) w% [) _( {- h) P - }
7 X8 M {* R1 B% o: { p1 p+ K - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
* c! N! f$ @: ^) ]( ~ - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
8 \- ^9 S5 H, k& y; b - }
& U! |8 y x' B - pose.pushPose();, P0 D% {; {/ Q; w7 q( S
- final int newLight = convertLight(6);
. V* l9 {" t U1 r* p - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));( R8 R8 a M) J0 _9 Z% ^
- final float lineHeightSmall = (y2 - y1);- i* N1 \; ?6 N, i+ h" L; R
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);: m! P$ t" _: I! f! _+ p6 ~" Z
- pose.popPose();6 @. q$ w! G9 o% D0 c) |
- }1 V% ]$ ]4 s* G H
' z9 i; I& B$ g' [- private RenderType getLayers(String texture, int light) {
6 ?. E+ u' O/ R, L - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
+ `" c) S( M8 I ?- K# @8 i l - }
, P; s* B1 k. W7 e. h - 0 k: h. B7 i1 J
- private RenderType getLightTexture(ResourceLocation texture) {
, w) P0 j7 s4 w" |3 m - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
8 ?2 o/ o" i6 L( v8 W" B( g - }
8 g* s* `% K7 z0 `# |
5 T1 _& ^! A5 s- private RenderType getTexture(ResourceLocation texture) {4 R; t" B' s4 e, A* j- R4 C9 ]
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
% R2 |! a8 F" w - }
- H$ c+ Y5 L. p4 V4 C* F
& a+ H0 ^ z) Q8 O- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {: z, X( w3 e& a/ L+ |" n' g# `9 z5 Q
- if (cache.containsKey(identifier)) {
$ }, [0 M* r1 y% u9 g9 T/ R4 P' _$ Y - return cache.get(identifier);, l: h+ P# r6 \7 `, ^
- } else {% Q* N# I5 ~: ^/ Z0 r4 T+ H Q7 I
- final RenderType renderLayer = supplier.get();
1 O! S) f# O" c! e% x9 b - cache.put(identifier, renderLayer);+ I! k! q8 r; e
- return renderLayer;
9 q1 E" y. @' A- V C6 Y7 W, u* y& ? - }7 J% W6 S4 C, n4 x$ P, l
- }
+ D8 W& Q2 l8 n; I: b" j( _# |# i - }
复制代码 |
|