|
|
4 g1 W' g! N! _( o
行,这个怎么样* d6 t! r1 ^* L" v3 ^) P8 D
- package com.xhg78999.mtrfac.render;
; ?: o7 U+ [4 h* {. \' g7 Z7 \9 ] - 6 w0 i1 ]+ _( X6 X4 D0 o j2 Z
- import com.mojang.blaze3d.vertex.PoseStack;
( N* l: b! J: X6 A; O# ]9 ^( l - import com.mojang.blaze3d.vertex.VertexConsumer;. v+ w j: o' k+ b" x, o" L$ H
- import net.minecraft.client.renderer.RenderType;
- ~3 |6 |7 h4 s/ U" l7 ^+ {" q - import net.minecraft.resources.ResourceLocation;# L+ N4 |& C1 I- k0 ^# E1 N
- : l) C- [9 ?# a( p
- import java.util.*;
3 `' e5 e, N0 f5 ^& Y% `
6 I' F6 K6 _! u* ?! Y) |2 C- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(3 t) f: I/ l0 \9 v
) A$ H' y: J: v. K9 q- j8 ^- public class LineRender{6 P' X' O! C/ {
- private final PoseStack pose;1 P% e- y' C" h# W4 W( o! o
- private final MultiBufferSource source;
2 H) ?9 y) E5 h: p - private static final Map<String, RenderType> CACHE_A = new HashMap<>();3 ~- _! c E9 F2 G7 X, M6 y
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();4 s: b& Y$ Q2 X4 v `- {0 ~
2 ~, E7 f. B4 H. m, s0 W# K+ i, R
. ?* _! F8 [" [5 n8 r2 z- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){) C' {9 [- j3 x' [
- if(x1 == x2 && y1 == y2 && z1 == z2){
5 C) L9 Y0 T2 ]5 I4 i - return;
+ ]3 v: I' b& l - }; z6 J7 t# b2 T4 u1 ? f) W: A
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
, c$ J" d* W! }* @ - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");# v4 E% `( N/ D; }: Q0 _( ~
- }
! h* c. O+ h) ]! N( V - pose.pushPose();
. n0 a- D& |4 ~# n5 A! h$ t. h - final int newLight = convertLight(6);6 l- x2 k2 I$ D! c1 ~
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));0 F5 |! P- J7 s+ F
- final float lineHeightSmall = (y2 - y1);* B& i5 \1 W1 @
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
% ?# V- z( ^& j7 x - pose.popPose();1 Y8 w% q/ W g% F* ?4 L
- }
( {8 L- S+ p: \ O
- s+ N! h- w, R# M4 E$ _- private RenderType getLayers(String texture, int light) {, M& ^, Y4 q; M
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));. A( q$ G; T) L+ h) a
- }1 _0 P* x( s8 V6 @' B/ F
$ V1 f: N) L# o' D3 x# ?- private RenderType getLightTexture(ResourceLocation texture) {* S- }! k: g* O, A0 K
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
, R8 ^5 h0 b9 _2 w - }
* S( x/ {$ L8 t- ]6 b; E5 a3 I
" O& d+ q' a; N: W; K% p- private RenderType getTexture(ResourceLocation texture) { F) w& Y0 o( Q( B ]0 A
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
. F ^; f; y! ~$ O+ z9 P - }
$ ~& D5 b7 P7 N8 m' w+ C
+ R7 j( Q, W" W9 N4 R( b8 w4 k- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {. P( R, l f+ _1 I+ Y
- if (cache.containsKey(identifier)) { P9 b) m2 o7 Y: ~2 O0 N2 i
- return cache.get(identifier);0 ?6 ]* {; _2 ?) ?# I
- } else {
_7 ^6 g( c) u- R3 V' q; `3 X7 p - final RenderType renderLayer = supplier.get();
) C2 v, N7 X, O/ w - cache.put(identifier, renderLayer);
, J( F1 [' r' D M( @7 x* v - return renderLayer;
& ^" h0 C' ^- e" J" b5 X - }7 J+ ?8 L8 L9 P4 k( N, v. ~8 |
- }
" ~0 p: \# F6 \2 V5 u - }
复制代码 |
|