|
|
0 |0 z+ r0 ?2 D7 W. f行,这个怎么样* u, X% E# l0 A& b$ s( q% c2 W1 C
- package com.xhg78999.mtrfac.render;
3 V+ j2 j# A+ O+ N0 T* \8 t; c" A - 3 h# \! O' o% q
- import com.mojang.blaze3d.vertex.PoseStack;8 G' D- C7 y5 o
- import com.mojang.blaze3d.vertex.VertexConsumer;2 z& @6 k1 o8 Z2 e4 K7 l0 |" o
- import net.minecraft.client.renderer.RenderType;, b" P5 @3 S/ g
- import net.minecraft.resources.ResourceLocation;
8 C8 L' y U9 [) E9 U1 X0 P. D
9 h3 p* C, m) h, h4 u9 K2 e! x- F- import java.util.*;5 L/ p! F' X, Y- j
2 N, R1 Z6 D' B( A% l2 f% u- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(4 z2 g- e) K8 }& ]+ J
! ?( A/ O' z3 w- public class LineRender{# s: [6 F8 q7 f' u' h! i: g
- private final PoseStack pose;# y* q, ?$ I& c4 K9 z3 a; [5 n
- private final MultiBufferSource source;
8 W* ~1 l5 N" m0 F - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
# ^) G3 V! l4 ?: y - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();) [1 I+ `( x8 |- ~) u
) h; k; _% E( I/ d6 j; I/ R
4 J) O# F. l: B7 ]- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){) D+ u8 T5 l4 t! K) a
- if(x1 == x2 && y1 == y2 && z1 == z2){
7 m9 P8 r. C2 Q& J6 u - return;
" @- R! }4 T* n, x/ C9 ~ - }. H$ T; _) ]' ^+ x; o
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){! X. v6 x6 o5 F( ?6 ~7 Z
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
! y3 T S( b; x" e/ W. E, R: Q+ u - }
5 v6 B" E2 ]6 o' m9 J - pose.pushPose();
% B9 b1 ?3 E& g, D - final int newLight = convertLight(6);. W% D) v+ I3 x1 @ p( P
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));( {' ]+ l0 N( w4 s) b
- final float lineHeightSmall = (y2 - y1);
}3 t' N1 x. h9 k1 x! ] - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
) J& [! ]& p) Z( ], w - pose.popPose();- K7 @9 R, A+ t" E! k6 w R4 c
- }0 I1 L& b: F4 k6 @6 N8 f
- 0 E0 a8 w, W7 n% {' }
- private RenderType getLayers(String texture, int light) {+ j8 u& G. l3 G3 A3 Y0 e% K; B
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));& n4 g1 K( q4 g
- }
3 y8 R4 N& o' r8 L- b$ `% o6 G - 8 j* {' T4 t6 ]6 d3 o4 ]$ A
- private RenderType getLightTexture(ResourceLocation texture) {
' @- x( k- Z% S1 {/ |- s9 {( {- z - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);: A- g8 K- S6 `/ _
- }
) w; T4 t; z7 u& u a - * I: o& f4 r1 W; K
- private RenderType getTexture(ResourceLocation texture) {& H f* v8 u. q( K
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
* n+ V5 H9 Q8 W; Y1 `- X E - }
# \' |) l( P2 |$ b. N - 2 [4 {0 l2 U% r& ` v w# S7 y
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {- \8 i" u. H; p: `( z! ?- r4 P' Y
- if (cache.containsKey(identifier)) {
3 o5 N6 [+ Y! |7 @3 d/ n - return cache.get(identifier);
* r: A$ g$ e" e9 j. b& \- ^* H& T5 G - } else {! v3 ?( F- k6 ]4 D/ H @) S
- final RenderType renderLayer = supplier.get();6 t1 P n, r8 R& o. R
- cache.put(identifier, renderLayer);
}2 x+ ^/ ~7 w) e0 d - return renderLayer;7 f) k& J% ?0 a( u0 ?& A! l9 t
- }- Z; G7 F. Y$ H
- }
! B$ O* M* _8 @( ?/ n - }
复制代码 |
|