|
|
! l p1 Z, {2 ?' e$ G% o( b
行,这个怎么样
3 m) T& K8 t* ^1 E$ ~1 \- [- package com.xhg78999.mtrfac.render;
- ]+ P; ` ]1 R7 y+ v' ] - & ^# y6 i+ R( a) i( m
- import com.mojang.blaze3d.vertex.PoseStack;
* H9 A3 g) R5 A- `! D" J# b - import com.mojang.blaze3d.vertex.VertexConsumer;
& M% m, F& O. r8 T: o - import net.minecraft.client.renderer.RenderType;) q+ K, H/ Y' |; \
- import net.minecraft.resources.ResourceLocation;
, K, @2 j4 {6 A: K1 @; S% J - 3 K# S. [+ Q; C$ E" A) A5 I
- import java.util.*;
% A- i. x# v" y3 F6 V* Y
# y |2 ?; C# C9 I' D- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(2 Q- b7 m9 W& i# H8 G2 Y; b
, Q. A7 c1 P3 O" j3 ~1 m- public class LineRender{
6 N( s; ?8 d G2 }. E5 M' g: j7 T - private final PoseStack pose;( j9 \! j7 }# g" b# [6 Y
- private final MultiBufferSource source;. s! s, x7 v6 A; M; V/ r
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
2 x& e& h! U. L2 k% u# \( A - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();- [4 P% f- D7 c5 `5 N
. Q% N7 ?+ ^) J9 J9 j/ i h4 b+ P& j# [- ) \( g% G+ y: G. o# \+ q( R5 W
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){0 ^/ u$ j4 R9 c1 A5 D
- if(x1 == x2 && y1 == y2 && z1 == z2){4 T; j$ n! ~) L, G8 t' B9 z- E: b
- return;
2 \# u9 s$ g9 r0 A* }; c - }/ S/ A# }8 ~& A6 K3 D# l) G& T
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){; p. q& V/ g( V9 P
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");& r% }8 J& M7 H$ X0 I/ ^- f! f( W
- }
. u, F. a- m* ?) W2 _ - pose.pushPose();9 m- l. k" u1 G7 V6 {7 X% J
- final int newLight = convertLight(6);6 b/ z o4 W+ v; ]) R* Y
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));" j: b! a7 s; T* y
- final float lineHeightSmall = (y2 - y1);
0 ?+ \. Y" D$ A! x) y - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
1 V) _# W0 G2 |3 [ g: X- d - pose.popPose();2 O; n7 q( i8 r
- }# Q+ v% O. V. z, V
- 2 [5 {' |# d# l* T$ L
- private RenderType getLayers(String texture, int light) {. F: V! i2 o3 C7 l" H" l; \; K0 A
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
2 B. o" k6 I$ [6 O. C - }
+ h( G G, t X& o$ i* X2 W
1 ]% X+ y7 e, u9 Y _, k- private RenderType getLightTexture(ResourceLocation texture) {5 J! V- W/ [# U
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);* F2 y' i; I+ F z- d' f( @
- }
0 F0 m5 M8 }) U: v - 8 O6 {$ h2 w: L u( z* V
- private RenderType getTexture(ResourceLocation texture) {
- y- J& [3 e) c8 W+ F - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
- n/ \! @3 T6 I( } - }- \3 r3 T6 [4 S" u( ^* V
- % s* V5 Q, k( ?2 ^& t9 j
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
% c. `$ D6 a! T - if (cache.containsKey(identifier)) {
: o) b1 X* O& G, g* \ - return cache.get(identifier);& ?% F" j' J- A" S
- } else {- A" G V) O) s r' v1 Z
- final RenderType renderLayer = supplier.get();/ k) q. z" E6 c
- cache.put(identifier, renderLayer);
s: P) M/ H3 \. p - return renderLayer;
0 M$ O' o, ]' _" c9 J* g$ L" A - }0 E' z0 f3 ]) k
- }
% y5 q7 L, A. N$ ^9 f# H( X - }
复制代码 |
|