|
|
/ f3 L( p$ v5 [ D行,这个怎么样* C* J% G5 U8 r7 r5 I ?1 \
- package com.xhg78999.mtrfac.render;
( X% n: ~5 K: B3 H - / S: U( k4 o k- I# ]
- import com.mojang.blaze3d.vertex.PoseStack;2 e8 j0 t( S. t( p. B/ x! ], z
- import com.mojang.blaze3d.vertex.VertexConsumer;
* Z5 t8 l1 G3 W }- u - import net.minecraft.client.renderer.RenderType;
( J$ q& l& O( v! g, w - import net.minecraft.resources.ResourceLocation;
l, g1 t9 Y M0 ~% Z/ h5 y - % S2 P6 F3 r& F7 U0 P) O9 v* s
- import java.util.*;/ Z: H5 c) B6 Q/ H# e$ Q
. M0 Z+ z: ~; [$ E. q9 R- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
: f* I* T2 i! o+ A9 x' [" e3 ~. ?1 z9 Z
: N( G4 \7 v5 P8 r3 D- public class LineRender{
6 A$ [% `4 H8 q& H7 ] - private final PoseStack pose;( S0 e1 D( V6 S: G1 W
- private final MultiBufferSource source;
4 F% P F8 Z0 Z5 Y% Y# T - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
w% z- ~+ y1 r- A. u/ Q/ Q - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
( E) T6 E( V* C3 |2 i+ F
$ A% `5 Q4 U6 |1 D3 S- 7 j- Y; }& u4 E; P4 l; x7 U! C
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
4 _ p7 u5 q) {; v - if(x1 == x2 && y1 == y2 && z1 == z2){
0 W! e2 I: f; A# `- Q: B: G - return;
) i0 k- s! G1 ~0 h - }. {, M$ {5 s9 N3 c3 i! s$ C9 s5 H
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
1 p' [- }% f1 F8 e - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");7 O1 ` A; }4 b' K9 U: ~4 _& K: ]0 d
- }
, u# f; |3 U9 K7 y - pose.pushPose();
, L, c6 X2 C0 p9 i. t7 f - final int newLight = convertLight(6);
# {) K+ L g$ q8 z0 o9 ^ - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));1 \6 `0 X5 ?( o x; @3 j: j
- final float lineHeightSmall = (y2 - y1);6 d, {: P9 k3 n
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);+ ~( v& p/ c' V y
- pose.popPose();5 M: z; o0 b- w, M, k# X# T
- } h9 L. l2 q2 }) j0 N2 j) W. \
- ! I9 v. Q5 k! S, n$ g! [, X
- private RenderType getLayers(String texture, int light) {3 u5 k/ X# G. A' P
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
% k! T6 X' B' e) r% k' d - }6 i) D* ?% d, c9 d( d# B! u% d
/ a5 @' m. T6 t1 N N- private RenderType getLightTexture(ResourceLocation texture) {' Z. U# ?) y& c% z6 {7 R7 k
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);+ M8 P1 D: R+ s. h# N
- }
) k' k6 h e5 }1 v8 t5 n - ) s. W1 Y; B2 Q5 L/ K9 f
- private RenderType getTexture(ResourceLocation texture) {. f% [- G2 ?( u2 v+ _ M/ o
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);7 |& F4 [7 A K9 C4 U
- }( c! p' `. N' R, |
- ) V' q+ \0 m3 C9 ~
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {' A* T [4 U6 J# L0 N# D
- if (cache.containsKey(identifier)) {
8 @& a% F5 n# l3 C8 G8 j. F - return cache.get(identifier);0 t. ^* J& j4 r' J; T
- } else {
1 N5 H# @' W# r; e! C) S - final RenderType renderLayer = supplier.get();& A& b) Y( X9 G2 [$ k
- cache.put(identifier, renderLayer);
2 B3 D- z2 O/ o. b9 K F1 V# c - return renderLayer;6 }' x H5 K1 D3 H; Y9 d
- }5 _; r/ V) D4 |( ~1 [3 ]
- }
" L8 p: h4 v" S4 F8 K j R1 n - }
复制代码 |
|