|
|
- b5 e1 l1 q0 y+ S
行,这个怎么样
. O1 e% F" j) a& ]3 z5 x. I- package com.xhg78999.mtrfac.render;
/ i+ \3 V6 T" B - / ]6 R. s/ V; G( z/ c
- import com.mojang.blaze3d.vertex.PoseStack;4 D( r- ~. g0 i: W2 i& I
- import com.mojang.blaze3d.vertex.VertexConsumer;9 V6 |) F: n- {0 ]; r$ L) @( V. n
- import net.minecraft.client.renderer.RenderType;
- W0 }0 | x4 l( O. A - import net.minecraft.resources.ResourceLocation;
4 f1 D% z8 a; s2 b0 s
* e0 t4 E9 R* ~7 {; b" v& W- import java.util.*;
* E4 r0 F0 G( U$ q - , O( `) ~2 ^0 N! I; A
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(' [* A" a S* x' M$ u
- 6 w; ^5 I$ p; x. O' [
- public class LineRender{
' K/ M6 c+ n, u5 m% z. p: [ - private final PoseStack pose;
9 A3 }* |) n: C* K, c - private final MultiBufferSource source; a6 q7 e5 S U2 L# [4 Z
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
# @9 q! u/ Z/ K; c: L - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
' Q! j* y1 J; S2 l - + Z b7 o7 s- a. ~4 f
- 5 [7 L2 O& p, ^) J1 c. h# f, b
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
/ u% [ x( j5 x: @/ @% G - if(x1 == x2 && y1 == y2 && z1 == z2){
) x4 }! ]. J+ i' z - return;2 b/ S0 Y h, r
- }
4 n' C$ u1 X' k: f; B8 A - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){4 j7 e# `! v* a& Q2 b6 m; g
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
( s' K6 Z% S; k; n& {6 t1 Z; A - }7 U; r- K3 U' t M4 t
- pose.pushPose();
[' Z6 d, S2 p6 q. S6 T; r( R/ n5 ` - final int newLight = convertLight(6);
7 e/ m) X# ^/ Q: V( d - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
& h& _+ B; b# y! }! ~ - final float lineHeightSmall = (y2 - y1);
0 z# j+ X3 ~, J9 Q0 Z, n0 w - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight); Y5 N, Z" ?! H( Z% _
- pose.popPose();$ i4 N+ X4 }8 k% x( J3 S
- }$ l6 ~. ~+ b$ a1 L
- 1 C- ]. s# V& E7 g- b
- private RenderType getLayers(String texture, int light) {
1 c6 H/ G& o+ M2 K - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));. u$ E3 T; V" }4 P) V5 u
- }
0 c6 z8 w' j5 O2 {: o - |# S b8 W+ r l# @
- private RenderType getLightTexture(ResourceLocation texture) {/ g4 F0 L) f8 ]0 L# l: u
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
$ B8 I! U5 s: v+ u - }' C X* U: a( z) p0 O. {: X
4 N6 E* W" _& k% U; q; |- private RenderType getTexture(ResourceLocation texture) {
E5 c3 }* j0 f- d( g% [, {, c, V - return this.cache(texture, () -> entityCutout(texture), CACHE_B);" h6 _+ T. u& Y7 {: }; F
- }! o- Q! I# D$ k! \; O. z+ Y' [
7 V6 L' I* A, `; w9 P) A' C/ x- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {* m$ F1 B! S' _: Y8 d1 O9 v, U
- if (cache.containsKey(identifier)) {
n, \. p, l3 K3 H9 O$ R - return cache.get(identifier);
: l7 A9 j5 i, r& b) i/ C6 F' z2 h8 d: y! } - } else {
6 y" t7 ?0 K# ?7 [# V - final RenderType renderLayer = supplier.get();" V3 b! s0 r: Q: \( m4 a
- cache.put(identifier, renderLayer);
9 V, d* U+ p8 \5 Y, p, c9 h - return renderLayer;; r5 X& p* w% s0 \/ y5 [
- }
$ n7 Z# }7 ]0 m' N2 m' i5 L9 H - }5 y: i p/ A( ]. v
- }
复制代码 |
|