|
|
' z5 E: m9 r8 u
行,这个怎么样3 t4 ~* v5 c g. G' t7 U2 ?( a
- package com.xhg78999.mtrfac.render;
: k! g0 X+ h, G" L! U, X - + L7 n, P* Y! J4 {6 Z
- import com.mojang.blaze3d.vertex.PoseStack;) G8 d4 a: `8 W3 R5 @
- import com.mojang.blaze3d.vertex.VertexConsumer;
5 q; x, q# M7 Y X( y9 D$ T - import net.minecraft.client.renderer.RenderType;
8 G. h, i% w* h' N: ?" e - import net.minecraft.resources.ResourceLocation;
3 w8 |9 R0 f$ D1 k; O2 z: n - 1 u, y0 ~; S, J, _$ _: _
- import java.util.*;* S2 ^4 I4 W! `0 ]+ D9 q5 v
: s+ y& W8 D3 ~3 M- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
& q$ [/ L6 I- M) c. V. s - 5 l$ b9 q$ @3 f, V( I
- public class LineRender{* \4 j8 N! | b s0 `) `
- private final PoseStack pose;$ e' O6 s( W& p% P4 I' d$ n, z% b
- private final MultiBufferSource source;
9 y6 V- q+ T- e& S1 I2 a7 u - private static final Map<String, RenderType> CACHE_A = new HashMap<>();) a% V* t6 [. D
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();& E* {& m! Z/ j1 f2 L; K) D
- " P8 U/ R) i! V- x
- , _! ]: F- m0 {% V }- X
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
8 }& A0 Z4 V! H# t; _8 g9 `( P8 E - if(x1 == x2 && y1 == y2 && z1 == z2){# l! t/ h4 h: h0 t0 A: m
- return;
( V; f. J* k( b+ w) q5 d% m - }
1 L4 I5 S% ^. a$ G7 H Z - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
: Y5 U; p. ` d4 U3 ?; w. R - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
0 r! x1 F1 B" T/ r - }
/ c/ l7 l' u+ Z4 E7 q7 t) t* T - pose.pushPose();# P+ A# |, C2 D( \
- final int newLight = convertLight(6);. u" s+ ?1 ^6 f5 l+ n. |1 J
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));; w1 J0 x3 E& O, L' Y$ ?1 T
- final float lineHeightSmall = (y2 - y1);, I2 p- G, T; G$ `* a
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);2 i" d6 y8 G X
- pose.popPose();) w% l% T' e2 V+ W# k" K
- }
- E* w" ]% W8 E! N7 I- ~ - 2 l. L6 q8 q0 s- `2 A9 r! c$ f
- private RenderType getLayers(String texture, int light) {6 }5 Q1 ]( b( p3 D" J1 b4 Z0 y
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));2 T$ j1 ?) r6 E ^( D# S
- }
9 i* C I2 j; u3 E - 8 Z$ X6 m/ {, |) N
- private RenderType getLightTexture(ResourceLocation texture) {5 Y1 i' s3 ]1 S$ ?- b
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);' C: {! n6 H8 h0 d3 H9 U5 W3 T8 v
- }1 E2 F6 |" |# w Z% \
! Y7 ?) j1 { Y0 _0 S) E- private RenderType getTexture(ResourceLocation texture) {
* {: N6 C- G+ d9 R9 Q - return this.cache(texture, () -> entityCutout(texture), CACHE_B);) F4 z0 q" `+ e$ ^& T4 d
- }
. M% i: K3 p, k/ I a7 p$ T - ) z/ K+ W' K4 L$ I" u
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {/ K; C; F/ n. A6 D: T
- if (cache.containsKey(identifier)) {
+ o! ?+ d. [# N, ~6 m- I - return cache.get(identifier);
. o" X* `, R: y9 L2 J4 ]0 } - } else {
7 Y0 N V' m( A9 M - final RenderType renderLayer = supplier.get();
4 x6 f& L4 Z5 i9 U/ @ - cache.put(identifier, renderLayer);* b2 m4 ^ p5 x3 W7 A
- return renderLayer;/ N# o( c" m3 [5 j
- }
9 e" W$ k" u& i - }7 A5 J2 Y/ N( [1 I- V
- }
复制代码 |
|