|
|
, ~: j" Z1 S; `* C* q$ P
行,这个怎么样/ t7 S( G. q4 i! Q! {
- package com.xhg78999.mtrfac.render;
0 G+ ^& w% s- L6 O
6 S, _1 p8 W W) `9 X7 u, O: {- import com.mojang.blaze3d.vertex.PoseStack;
1 ^( [ b& x ?8 u - import com.mojang.blaze3d.vertex.VertexConsumer;
/ i2 q& m" Z1 G% [' C+ I, r - import net.minecraft.client.renderer.RenderType;* e8 H! n y& P- s- w4 o& O+ {8 N
- import net.minecraft.resources.ResourceLocation;# L. b5 s% x% G4 [1 T& c+ ?
( W# C0 j# D3 B6 D- import java.util.*;
% w* E. F3 ]# C/ ^* l - 7 y; @3 J3 Y7 O+ t6 `
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
0 g* S8 H% j3 M+ V( f
+ }0 R5 j4 X3 |- public class LineRender{
; I+ U. R, h4 u3 h6 B - private final PoseStack pose;
/ B9 d: c; W1 g' P - private final MultiBufferSource source;+ h) B7 Y- W2 S8 F! ?; H
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
% T3 a3 A2 M& Z! a; P' B- u - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
8 I6 `( _& x$ h6 ^# _! y - ( |0 K7 X/ m8 x% e7 @
- * n- n8 e( Q6 `. ]' _/ o# `8 M
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){2 ~ f0 d# P* C9 M O
- if(x1 == x2 && y1 == y2 && z1 == z2){
' E( P) U$ {# V- [6 E - return;
4 T. ^: L+ V8 Q7 b% [ - }6 I9 l9 g# @+ C; ?
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
- a6 | `% I1 w - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");' y) p4 [# X0 a4 ?2 W- |* S
- }
% [# v, t; D, s( n+ \8 Q% \/ m - pose.pushPose();; i! ^2 }7 e) I( P* K
- final int newLight = convertLight(6);
$ m# O" x: N1 G$ N9 K5 c8 | - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));3 v4 H% y% S" E8 b# D" t2 d
- final float lineHeightSmall = (y2 - y1);+ }* C2 F8 O; p4 \
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
/ \& p: l% N; t- ^5 t - pose.popPose();) e0 D( x2 r+ [8 H/ x' f
- }
: u* V3 y1 U! s0 v; l - , {+ Q- {% G& Q
- private RenderType getLayers(String texture, int light) {0 {; q# O: O2 Z: y& @6 j
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));8 A+ n' t& {0 U) N2 Z1 r
- }8 n- d( b1 q$ ]: E
7 m/ I G; H( S: b2 ~* i7 w8 y7 g _- private RenderType getLightTexture(ResourceLocation texture) {
- g9 N& W" z( W& i* _/ v& b - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
. z4 {) U& f2 R+ X( b: i - }% L( [* F; }8 r* c( X
8 f) h5 d1 k7 _3 f' R" U$ P- private RenderType getTexture(ResourceLocation texture) {; x+ e% M% y0 y; v% [
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
4 `: i+ r/ z. @3 K0 P0 G5 I; s - }- W" p6 l4 v8 }7 x
7 m8 \( Y% q" W* r# R- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
& b8 w, G- X; W( s# m. `7 N- c - if (cache.containsKey(identifier)) {9 p4 |2 v# U$ _) R) }# Q5 q
- return cache.get(identifier);
: T- Y/ g0 Y, B6 o' `' a9 S - } else {/ T3 @% C: ?7 k8 j! e$ u1 H; n# }
- final RenderType renderLayer = supplier.get();
- \# I+ c+ c- x( A - cache.put(identifier, renderLayer);
% s- |9 l0 | w0 h% _ - return renderLayer;) ~* f( C" A# G: ?8 _5 Y
- }. W |4 a ]; n7 z$ z/ e
- }9 t' y" K1 Q" e
- }
复制代码 |
|