|
|
, ^) D) _ A: k, j
行,这个怎么样" A) e3 \/ f% n
- package com.xhg78999.mtrfac.render;& e. |. v$ G' P7 a( p' B
) s8 ~6 ?' K7 T# G' v0 d- import com.mojang.blaze3d.vertex.PoseStack;( q; p; N: {1 K, V4 z7 L% P
- import com.mojang.blaze3d.vertex.VertexConsumer;
1 I7 O* {9 v8 r2 g5 B, }& y4 i - import net.minecraft.client.renderer.RenderType;% U0 b. g+ V/ @& V. G9 O j
- import net.minecraft.resources.ResourceLocation;; \: k+ |2 b2 j7 f) t8 a. l; N
f! K: D" m. _: W- |; m- import java.util.*;6 D, W! {/ `0 r* p; W+ J
. ?2 ~2 E+ @3 b/ S6 A3 q- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
4 i+ J9 U) H6 R: z, f" O4 k0 q - 0 P* `7 w& q3 x
- public class LineRender{( I& H7 s3 X, k( o7 e8 r; m1 Q
- private final PoseStack pose;% e! F/ N8 }' b: m/ e+ T' _
- private final MultiBufferSource source;; S( s o: A4 Q/ t/ q, Z- H
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
( v2 @% o7 l- X% p$ q6 ] - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
j# l3 Q/ A3 o/ T' v
5 C/ j0 Q5 s" V# k2 j9 V d8 }
+ V: ~! B# L& o/ N7 @- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
! q" i7 @7 k# @/ G" g' U" X! n - if(x1 == x2 && y1 == y2 && z1 == z2){
0 }2 `& E- u2 [2 t1 |' O, ~ - return;
$ p. Q) l3 t T& |0 R" d - }
# P1 n' ]+ N [! G4 `/ T - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){; _5 z7 r l% j
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
8 ^. z+ h- |3 h% d( E - }/ C$ }) O3 E- p; L
- pose.pushPose();
. M: z% C; T6 W ^7 ~' Z - final int newLight = convertLight(6);
! I/ b6 }7 L) l* F - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
, d5 T& p4 u! a& O - final float lineHeightSmall = (y2 - y1);; d5 c- W/ U) D* S2 @- `8 T
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
1 v, i! H8 Q2 _$ @9 X% w# k3 D( n - pose.popPose();
. @' W" @, H, _ t8 O! P3 W - }
% a# A& `" k$ ^' o5 x+ W - ' ^/ M, U" u1 c2 P' e7 w
- private RenderType getLayers(String texture, int light) {- N3 Q2 Z$ T: a( g& E
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));0 Q& x3 m/ i9 {9 b9 ]# O0 [
- }; L5 l6 k' A, Z. A s# J4 N
' c/ j) L3 G1 o9 a5 G% `5 X1 O- private RenderType getLightTexture(ResourceLocation texture) {
- A4 Y( c( ~$ C8 S% n: v! { a - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);* D/ Y8 m6 p C+ u0 p% { n
- }
9 t5 v) ?) A. X( ] - / F# F7 y# H6 G6 p
- private RenderType getTexture(ResourceLocation texture) {: e% I% B0 \* B1 I
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
+ p \( u# ~! f9 y+ T, `- r - }
0 y9 f/ e$ K$ m) k N; L
: q/ y% ? g j0 V- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {3 B4 F# b) K: F, T
- if (cache.containsKey(identifier)) {
1 b0 X( H; K+ x4 B0 T6 V p - return cache.get(identifier);$ A' c! j9 k+ a- S* k
- } else {" u8 g6 _) G" Z# T
- final RenderType renderLayer = supplier.get();' v5 }' K' X# g. t* }
- cache.put(identifier, renderLayer);
8 T7 f/ O$ k# N4 d2 m - return renderLayer;1 g& h: D, b6 N, Y% n
- }0 v- @+ @) D( [, j+ P
- }& b( ^ I+ p9 ^
- }
复制代码 |
|