|
|
" [- H- `* m7 a
行,这个怎么样
7 Q3 F1 j- a l+ m! [0 X: z3 D& I- package com.xhg78999.mtrfac.render;& E: U8 c6 b' k; V
- % Z# I9 ]" j- t. j2 Z9 b, O8 F
- import com.mojang.blaze3d.vertex.PoseStack;( S+ u h( X; O
- import com.mojang.blaze3d.vertex.VertexConsumer;& a' ^$ P. f- W/ P) h' N
- import net.minecraft.client.renderer.RenderType;
" V1 N3 D& A& O! s6 w& B% ~" {$ q/ | - import net.minecraft.resources.ResourceLocation;
! h! {; U5 R% b - / Z5 {4 m% Q. d/ H
- import java.util.*;
/ X2 e6 d! z) H! h: U - % L4 W: a( f+ S* {4 |
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :( j/ m4 V. m, Y+ C# |
. x5 Y) P- K6 r" m- public class LineRender{( C. u( [* h+ N& f: L
- private final PoseStack pose;
- r. C: l; z4 V7 J5 S2 z. K - private final MultiBufferSource source;
" R6 E% u+ L6 W5 Q/ Q: l8 ] - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
4 o% w9 |2 \* \' i! k$ }) e - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
$ C4 \ I6 [/ X3 h" m5 W, x' Q! d - / ?8 c) x2 z' x! R4 W1 Y
7 o6 d8 y9 C- N) q% d8 b2 e- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){2 D6 j# g" x5 m- k" Q% J
- if(x1 == x2 && y1 == y2 && z1 == z2){) n! l" { m" e/ @
- return;
' H5 |8 o" K; P& G2 Z" @ P$ N! ]7 R - }
" u8 \2 T/ e- a q% r5 B' C - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
, q) m6 }) @, j' R4 Z$ s - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");) I' a9 [% w' t; F% q4 d
- }
- N! l# ?1 _) ?9 H - pose.pushPose();
' i2 t& F6 M( c$ R- y - final int newLight = convertLight(6);
1 b' M4 y: K) r0 k - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));9 ]9 }4 J& F( V4 u4 [
- final float lineHeightSmall = (y2 - y1);
- W5 a U8 w. F - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);+ l- Z: x- p/ d6 N/ K0 s7 H
- pose.popPose();
2 S. S) G$ F- b' G. E3 f - }$ @" y" B3 a i: K& ~
- . M+ B( ?$ |" n( ^6 v' M. @
- private RenderType getLayers(String texture, int light) {
( O7 g0 p! E" Q: _% I& e - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));! k3 m3 Y- s! C7 W; g9 f$ V
- }
' J$ j1 W# W& q - 5 P' s% Y1 W" M* y! J' w
- private RenderType getLightTexture(ResourceLocation texture) {( r8 o' w- ^( R9 B1 H' K& {5 m
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);: T" ^: ^/ T) x. N
- }$ |' y3 C0 u# j1 V. p
- _( d4 Q+ T S E! U/ a# {9 G- private RenderType getTexture(ResourceLocation texture) {
9 ~! x7 ~9 s; s& W: W- K- H' A0 k6 L" \ - return this.cache(texture, () -> entityCutout(texture), CACHE_B);: _ s4 l* h0 H8 W# m
- }7 H" v) j p: `3 J
( s$ r1 \/ R4 ?2 D' M# J! B* W# A- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
* _, b; F) E* A3 G% L' ` - if (cache.containsKey(identifier)) {) d2 D, ?3 Z N2 v7 K4 l m
- return cache.get(identifier);% c6 c* I* m; Q/ m, R; r. n
- } else {
' N8 Y, Y! `. \; }5 M! W - final RenderType renderLayer = supplier.get();
, T. z6 `% g2 L1 [5 u, `. D# p5 @ - cache.put(identifier, renderLayer);6 ^7 p1 j1 b3 h+ I6 A/ J% b) [ k& }9 Q
- return renderLayer;
: H4 \: y' t y' O - }
* k; Q0 a+ N' B* w - }: _* c/ f/ a5 a* o) @
- }
复制代码 |
|