|
|
$ b7 K( o! }7 X1 c& W" s7 }" ~( a
行,这个怎么样
: i/ @7 K$ t7 r& m8 _1 R- package com.xhg78999.mtrfac.render;! e+ [8 e( y7 r$ {) z6 M' E
- / G$ a5 b4 d5 @8 B
- import com.mojang.blaze3d.vertex.PoseStack;. P. r6 H! E: u7 ]) p
- import com.mojang.blaze3d.vertex.VertexConsumer;
# v) c- G: ^+ v- D$ z# q - import net.minecraft.client.renderer.RenderType;
; s5 d" R6 q/ p7 M/ N1 v1 m - import net.minecraft.resources.ResourceLocation;
2 D, R+ f5 m+ W! ?* p6 @
* C# X- x% s1 x1 c5 b5 r- import java.util.*;' h' Y k7 c8 k
- 6 T0 ?& Z# y2 K5 ~8 ?% \# X4 p
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(9 E, O; f* u* R! _( [5 X
4 Z x% {9 X: V# i0 [' r" ]1 V) A. d2 T/ F- public class LineRender{
' I d* x/ C4 a' U9 m) q - private final PoseStack pose;
$ |. h9 w0 ~ Z9 {; a2 m" P! o2 f* n - private final MultiBufferSource source;! x: ~& G0 N) g+ a! |
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
! ~' }2 N- \* @ w/ W - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();+ C& P' i' ^/ _; K# T6 u$ f
5 T( k' V- Y- l$ F0 A4 k- ' D8 [+ y f5 j/ e6 Z
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){8 a+ {- M& m: p1 a5 Y
- if(x1 == x2 && y1 == y2 && z1 == z2){4 ~$ e8 q/ u) O% r
- return;
# b( @) X/ r( h7 ] - }
: T+ u4 ?1 d$ B8 Z2 u5 |/ `& \ - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){3 @4 i: L6 ?2 s; s5 y' Y. a- w. q
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
) h+ [( o6 Q( w6 M6 R- f: Q - } _2 t! n/ G& E0 E" U
- pose.pushPose();
9 m9 |& A2 q" Y+ ~7 t' d1 Z4 ~ - final int newLight = convertLight(6);% y' h4 G y2 W+ X H
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
; J [- r; y0 | - final float lineHeightSmall = (y2 - y1);0 \6 \+ e" v: M; T$ x
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
1 I6 m, y! l) U/ u' J' m8 t: u - pose.popPose();
4 X% `( }+ z( {- h% | - }
8 O' ~* Q8 X* t4 i4 t) G
& l" i$ i6 N; p& r# S- private RenderType getLayers(String texture, int light) {
: s2 g* |7 I9 H8 ~3 n& E8 f% w - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
: W6 A* m6 e& @4 p* t" U% K: D - }& o( m o# F. {/ o6 y* Y
- / m3 P* A, x2 B; C S
- private RenderType getLightTexture(ResourceLocation texture) {
]5 F" w6 M9 D9 }+ Q. ^ _- p - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);! q* Z! [: [( `3 x0 _/ @
- }0 D& P' @- u4 @& K+ s+ c
- 1 O6 `& {$ r9 ]" v$ y0 ~, A
- private RenderType getTexture(ResourceLocation texture) {
7 H. `, _. P+ K b - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
6 t2 M" V7 a V; \, \* h - }
7 Y! d+ Q& p) K% M) [8 q
5 @3 c7 c: D: z. X4 k" ^, Y3 w' @- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
1 ^. T( U8 R9 ^ - if (cache.containsKey(identifier)) {
- u2 A1 x* e5 d8 Z3 G0 }' s - return cache.get(identifier);: `9 d5 M, t- v. P( [9 N5 x$ M
- } else {
1 g l, p0 t1 K% y( X - final RenderType renderLayer = supplier.get();; M0 |+ V( p# @; u9 i5 N
- cache.put(identifier, renderLayer);, K. L" n3 P( o( o" G
- return renderLayer;
+ ^/ k, g; P! i% T `/ j - }
) W6 r. x- S, X- V - }
' x; Y p ?" W& k/ y; C& I - }
复制代码 |
|