|
|
4 @8 N) R. O1 J; R
行,这个怎么样( R3 e. Y9 P q3 a
- package com.xhg78999.mtrfac.render;9 B6 U4 F5 e9 h9 h$ Q6 a0 q
1 S8 O1 N" k' s1 f/ u6 a1 [) O- F- import com.mojang.blaze3d.vertex.PoseStack;
+ O) D p4 h) l2 g7 R; K9 x - import com.mojang.blaze3d.vertex.VertexConsumer;& n! V( |- t% C6 `# N" O
- import net.minecraft.client.renderer.RenderType;
/ r/ O' e8 c0 x* E) J9 I* c7 z; u - import net.minecraft.resources.ResourceLocation;' {- f: u9 t/ g. x# T
- " D/ Y* l2 z$ I$ J$ W
- import java.util.*;
! }9 G: u, j9 [" W - 0 n- ?& w0 f; Y- v5 w' ?% l: ` `" M
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :($ d& ]* y* @- }* C+ n; O; u
- , ^% x" J9 |! j+ h+ X) T% u2 J
- public class LineRender{
( g9 t; F5 I! L, Q. B0 C - private final PoseStack pose;
( w+ a; \6 O) n' {% \ M: R - private final MultiBufferSource source;
; G5 |; ?! J9 `% s! m! M - private static final Map<String, RenderType> CACHE_A = new HashMap<>();) ]9 C+ @" D2 T
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
: \- L$ t. ^4 W4 ~" w V+ s. _9 X0 w - 2 ?- B0 a& i. @9 [) g
- ) s" j# C7 K" R, W
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
$ `* v W% f1 w( d - if(x1 == x2 && y1 == y2 && z1 == z2){0 l. f' L% a; b2 ?
- return;( b3 d# c* t3 i2 g
- }0 H1 K6 K' p/ Y: g
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){" k" m( u, Y( B+ I
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");$ E6 ~; u2 B, @" |/ V9 L- S r& z2 ]
- }
4 y5 L0 K: P, o& O - pose.pushPose();
1 A0 O% g1 O$ Z; C3 U' } - final int newLight = convertLight(6);% O. o5 v+ d* r# [1 T" v# d6 U
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));# ?. k0 P( M' [' _# h
- final float lineHeightSmall = (y2 - y1);
4 a5 D7 d5 F/ ^9 Z# l- Z - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
( Y \& j, m) I - pose.popPose();/ V' N) A" s% X* F' V v% g
- }9 F; G$ w( k- M$ I2 _
- 9 G6 n' K/ P0 `6 z! o/ x8 O
- private RenderType getLayers(String texture, int light) {
/ ?6 ^# v3 Z) x" ~ - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));3 g) c4 g: L' `. ?, r* Z4 ]
- }
4 x$ u+ t+ T/ R0 p7 `6 @* \2 R' ^ - 9 w: o* [1 g5 n
- private RenderType getLightTexture(ResourceLocation texture) {
2 m" L3 W; k+ G - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);- P. w) a, D0 j0 b3 y
- }& d, j' E! P3 A6 B. F: a
- ) z, e9 R' z% V3 e# _: D
- private RenderType getTexture(ResourceLocation texture) {% G% i9 u4 ~( r# Y" t% i$ `* |
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);9 j* @/ @: [2 D; F% I/ I
- }( p% t: I; s0 R# w
; O" X8 U3 U. E& b- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
! G! X) w$ U/ I6 ~( J) e - if (cache.containsKey(identifier)) {
% O0 l* a, E0 G - return cache.get(identifier);, D! n5 P0 ~7 i- h# O
- } else {
4 r8 j9 Q- s- z* o4 A - final RenderType renderLayer = supplier.get();; _4 n: a* A& {( P' l% w6 z2 M
- cache.put(identifier, renderLayer);3 D z/ s4 v p; ?9 o; p3 j9 N0 N0 x
- return renderLayer;$ b& T1 |; g- g+ w
- }
3 a, P" f5 x/ Z1 \' L9 N - }$ M0 q7 C( f- g, `5 ^5 V; ]3 `% N
- }
复制代码 |
|