|
|
% h( u$ z a7 z' {8 ]7 \9 E: ]# z; g
行,这个怎么样
7 Q1 W; u& \ Z4 r8 q8 z( x- ~- package com.xhg78999.mtrfac.render;
( j e7 u) M8 U4 e( k$ K - * J% a' a5 n8 D4 T, z H7 E: s5 z8 n
- import com.mojang.blaze3d.vertex.PoseStack;
* G3 ?, y, |6 w+ R - import com.mojang.blaze3d.vertex.VertexConsumer;9 H" A9 C# Y5 v6 Q
- import net.minecraft.client.renderer.RenderType;' T5 I9 N4 O- c- W
- import net.minecraft.resources.ResourceLocation;
* A3 n) I; v' e b: m& `
" p! ?3 c" g2 e8 P o& a. ]- import java.util.*;2 N: {& o. m2 F6 r5 d2 [+ _7 E7 v% [
- 1 |! H" ~0 I3 X7 Z, z! I
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(9 h- Y& g. e8 s$ ~! R* \
- . H1 \/ S& q9 G. ]
- public class LineRender{
% I* F0 W! U! D) B4 t - private final PoseStack pose;$ D4 s- M' w' x$ z( v8 @
- private final MultiBufferSource source;
* M/ j7 M! S6 Z' w5 q - private static final Map<String, RenderType> CACHE_A = new HashMap<>();6 p/ T4 g3 s2 C0 b5 y* [0 A, a* h/ V4 m
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();0 `: h; x: v8 E
2 b( K& k4 |! R# k- F7 d
& [9 }& k5 P3 m" ?- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
; e, ^8 C5 u& ^5 ^3 y+ r) G - if(x1 == x2 && y1 == y2 && z1 == z2){
1 {9 p" C: P: L) V9 g - return;
+ V% a/ ` K3 x u3 l - }
0 p; e3 T3 h! s* J" m - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
! p7 D7 {& W( e( A - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
4 F0 r: Y7 ]- b$ g5 r0 i - }1 A- M. k( _$ Y: X& v+ p, W* Q
- pose.pushPose();
2 N5 E6 V4 J. ]) }' ^9 b - final int newLight = convertLight(6);. n* ^ d9 |) O# y
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
; @1 y0 m, M1 h2 K) n4 _; J L - final float lineHeightSmall = (y2 - y1);
( B# S) n) i$ I! K. p - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);! n$ d' A9 E+ {' h
- pose.popPose(); s5 y7 z/ e& X) L4 |( O. ]) A( ]
- }
. Z2 T1 i# @' c. M/ i - : A/ _! i1 @6 d' y# V# H
- private RenderType getLayers(String texture, int light) {
" J ?9 T3 Q, y8 a+ A - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
% \2 L' p/ [ N2 F) t3 D" f - }) O* y8 I4 |, X9 d* e5 B$ B
- 7 q7 s* C4 }) A3 L8 N( M, j
- private RenderType getLightTexture(ResourceLocation texture) {
* q) _: {; c- z1 @ - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
& d9 l8 b! y& d J8 C - }) B+ O) G) Z& t ]' L* K8 [
2 e5 @7 c+ e- n6 o1 R. c- private RenderType getTexture(ResourceLocation texture) {
& {; K' J3 V" _: c6 v - return this.cache(texture, () -> entityCutout(texture), CACHE_B);7 s5 g/ z$ Q% o/ f. @% L' _
- }
8 d2 W; d5 ]8 Z2 k# w5 S4 p4 Y
6 d; [: K6 I+ _& a) `" h) G- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {, t( f# r4 ~# D
- if (cache.containsKey(identifier)) {
, {$ k% R1 X$ ]9 a5 k- N+ r - return cache.get(identifier);4 j" y, d9 G k+ D
- } else {
1 o3 y( d8 |& Y - final RenderType renderLayer = supplier.get();
. n, s. W+ }! U! C - cache.put(identifier, renderLayer);( T2 s" ~2 }0 h/ A
- return renderLayer; E0 h3 \4 |+ o. L. I
- }( Z; P6 g$ p: ?! [# ~
- }2 t9 e/ \4 i+ n% d7 W! R6 u6 A
- }
复制代码 |
|