|
|
- z: [+ A& z3 e! M8 q( n
行,这个怎么样* o3 u3 c& W8 s- D# p
- package com.xhg78999.mtrfac.render;1 k) Q p$ G- ]; }; U# g; f
, `( j# ^+ S$ b \ f- import com.mojang.blaze3d.vertex.PoseStack;
9 U0 V1 m0 ~; b - import com.mojang.blaze3d.vertex.VertexConsumer;) \9 J# s9 z8 _' N$ p
- import net.minecraft.client.renderer.RenderType;
% B% Z( S8 {9 D1 @* C. R - import net.minecraft.resources.ResourceLocation; {+ K* b. {! c: {8 c" f- i1 F
1 G2 i6 a8 b( P7 x o- import java.util.*;
" I, ?9 ?4 O5 e# x9 K3 S8 D
: j* i& n' X1 d& d- p$ C- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(" E' c3 b+ I6 w" V: U: i
- J: F) f. ] L( z- d( I5 s7 e- public class LineRender{
6 G& k' e7 [0 G1 [9 O - private final PoseStack pose;
- W% I2 e t! R- _% |4 y; q4 `( K8 a - private final MultiBufferSource source;$ O D1 i/ L) J. {1 E% F9 f' K& w7 ~
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();" ?0 P* I- t( h0 s! ]# D4 A+ G
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
% q4 h8 L4 J, X! ?5 A; L4 h: U: B
2 Z- S; l( [* J4 K0 J
- n1 O( s9 ?! t$ e- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){6 c9 R! k" y" y0 h( E
- if(x1 == x2 && y1 == y2 && z1 == z2){$ ?2 y+ b9 Y* I y2 } k
- return;
2 a( o+ {" |3 M t9 b1 j4 Y - }6 C' x' V: [( O: x
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
X$ J0 t5 m) [0 Y5 }2 A7 ^4 l J - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
8 z* p( o" f R; R( { - }
( m5 R `$ f4 `+ g) K - pose.pushPose();
# I0 g1 M6 _' }1 M5 q - final int newLight = convertLight(6);! R) u" k) c& G6 L' ?: g, A7 v& @! G
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
# l9 n/ a4 n' ]& N - final float lineHeightSmall = (y2 - y1);
' ~ a. M; _' ^6 w - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
) d4 ?# P! K0 L9 |) _: X7 I9 V - pose.popPose();: e& G' X6 W# K Y( b
- }% O6 }2 h! j8 E; W4 O j* t( Q4 H
- V# i+ T, s! l2 a- private RenderType getLayers(String texture, int light) {
* G: Q1 f9 o/ b: {/ w - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));4 I9 Z! R5 w* O( B
- }3 P9 D& K7 [1 W# U( d I
- 7 J+ D( m, m* t; }5 \# i0 T
- private RenderType getLightTexture(ResourceLocation texture) {
( c. K; U7 o$ G. B9 E5 l9 J' V4 t - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
]4 k, S1 |7 @: H& P - }
5 E/ B. J- C* g) b
0 K# a! C/ ]4 [* p4 s- private RenderType getTexture(ResourceLocation texture) {+ M' b4 S( ]5 Y
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);2 U) ]2 {# M2 W5 X0 \
- }
! s8 }9 \5 }0 o U X7 x2 H9 w
* l' r2 m' C: \0 K7 o5 {- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
2 ~8 D0 ]2 @; O3 q - if (cache.containsKey(identifier)) {) W# Q2 A( t7 W/ L6 O; ^7 Z+ F
- return cache.get(identifier);1 B1 r7 Z L2 X: @: b
- } else {
5 N2 q% M" N4 R) c) ~9 K7 H2 y2 V - final RenderType renderLayer = supplier.get();) ^1 y" H4 Y3 g5 S+ l/ o- Y7 y' P) l
- cache.put(identifier, renderLayer);
; B/ V# u8 I- H& c X3 i9 M - return renderLayer;- i C" o; k+ @/ u& T
- }9 t+ J6 `$ s9 |5 K
- }7 Y$ j, d" G* h; Y# B' @) f
- }
复制代码 |
|