|
|
; @6 g* N! K' q! f* N8 z8 l
行,这个怎么样+ @ @. s6 T1 q( v" ?5 g% s" F; M
- package com.xhg78999.mtrfac.render;
) [6 q/ k' ~' h2 u; Q; x3 K
+ \1 @% ^6 p1 H7 Z6 _/ K: b- import com.mojang.blaze3d.vertex.PoseStack;
) B' M0 x' Y5 b - import com.mojang.blaze3d.vertex.VertexConsumer;( e: z$ z7 n- {
- import net.minecraft.client.renderer.RenderType;8 m1 y; a {, ]7 U# l
- import net.minecraft.resources.ResourceLocation;5 y' ^3 `1 _; \5 U' L% g
) t. }% ?2 ?9 `) X8 Y" g& X- import java.util.*;# Q, w5 x; i7 `: {! c( D
- ; ~7 M4 S* U' J
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
, Q& z5 R2 A& h: a; \1 W- b( W
4 z+ ^# g, b5 w$ f1 ?- public class LineRender{
: q9 G# D) u2 J, E) p& V% I - private final PoseStack pose;
! Z& L6 w( h8 Z% r' Z% s - private final MultiBufferSource source;: W9 C0 P2 A, U& W8 b
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();4 u: F) y4 p$ U2 B
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();" b1 [: ^! F' e( {
- ]. F- e* X) f7 ~# a$ t
- + }: P3 Q8 u5 a, T! j
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){4 w2 M% ` T% o3 W+ f
- if(x1 == x2 && y1 == y2 && z1 == z2){6 c) T; M" h/ D6 S
- return;8 p* C5 d+ @( ~. f! o
- }+ Q | |( ^- X( ~ z8 m
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){2 p9 P( i2 q5 h$ g- X% g
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");& _9 _1 j2 Y/ f$ x$ l
- }+ u8 T. X' }! n, S1 }9 b1 K
- pose.pushPose(); u% }5 S: |, l1 l( ~0 O8 S
- final int newLight = convertLight(6);" O& e' O8 B& |# B: }( @& b
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));- }- Z% f6 U# w) e
- final float lineHeightSmall = (y2 - y1);$ c* B4 ]& b# Z k
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);! v* `/ ^: Y# ?% o4 H
- pose.popPose();
/ R: S; B8 p k2 O$ x% x( t - }
" X5 U4 d! d- z! `2 w+ r- }( s - # s4 P2 u$ I$ n& A( {/ N) ~ T
- private RenderType getLayers(String texture, int light) {
8 O$ ~! N+ @" \" A, o, R- \/ S - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));) {) _7 J8 G, _3 R; n# S
- }9 V9 F8 _( ~4 Q
/ }5 |9 K n1 u( F0 S" ^- private RenderType getLightTexture(ResourceLocation texture) {
2 ]1 b1 `0 ]. l& f6 l7 G - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
2 k# ~) x* ^ t. g. N' T1 S - }8 i; W) V7 |6 B
- 5 W7 s g/ D; y% A
- private RenderType getTexture(ResourceLocation texture) {2 n( G5 A" X" R6 V; S
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);7 @7 O- K% B4 q
- }
3 V. d- a% L4 n5 Q - ' _( e- ^3 G( H1 |9 ^3 N) |
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {$ K- E" v+ f/ E" k5 x
- if (cache.containsKey(identifier)) {" b7 p9 e& y# h
- return cache.get(identifier);
, \1 R2 a# f& V) g6 e' ? - } else {3 ?: D1 m" O7 n/ V8 v& C
- final RenderType renderLayer = supplier.get();
6 H- O2 }( o3 e9 Z$ c$ t - cache.put(identifier, renderLayer);
5 {- m' p; T3 S' j+ C3 l ^* x - return renderLayer;# L+ _' N0 A/ L S7 K X
- }9 H( {- K9 K& B+ T. }
- }8 N H" P+ b/ p' D$ J# h! ?
- }
复制代码 |
|