|
|
$ i3 E! r' {# {/ A0 y# G行,这个怎么样2 r- _& V3 G( [- G1 E0 q& l. D
- package com.xhg78999.mtrfac.render;
" C. L% ?: z i1 N
! x* f& Z: h5 {4 j- import com.mojang.blaze3d.vertex.PoseStack;7 }2 \9 K; }( h7 \2 Z
- import com.mojang.blaze3d.vertex.VertexConsumer;7 n% [1 t/ ?6 x0 t* d' O/ ^/ w
- import net.minecraft.client.renderer.RenderType;
: F1 I; l9 V0 P4 O3 v6 u - import net.minecraft.resources.ResourceLocation;
& ?& r/ @/ O& [3 Y9 Q
/ m) r) L* R$ m! o2 r9 i6 {- import java.util.*;
: F5 i) r/ F1 J6 D' G: b/ B4 _' ^
9 [1 h1 N& K- e/ q2 E- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(, z! ^7 ]$ N7 `2 N+ Y
- 6 U P" {; \7 @% q
- public class LineRender{
1 }7 y6 {- T" r: l9 R! Q - private final PoseStack pose;& j$ l- v4 }) N8 o7 g: \4 R
- private final MultiBufferSource source;% }- D3 A$ B5 B, c6 W0 l
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
- R* P& {; @4 f% j; v3 P - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
\0 q) F9 @$ @* z8 ~. X - 1 Q& d6 j' e' ^" K$ h. o
- . b h3 m m1 E' T
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){( X+ J# I* G* c w+ ^/ a" p
- if(x1 == x2 && y1 == y2 && z1 == z2){6 A$ X H$ Q$ V2 x! i1 G6 G% H/ S
- return;3 K- Y/ z; i9 P" l8 w
- }
" p, U) g/ X- q0 | - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
- t2 N6 }+ P8 {/ s5 l7 m - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
. k1 q$ A' m* d* _8 s# f" W - } J; W! O2 v' d/ i) E& q0 V$ [
- pose.pushPose();9 I, L( D5 q2 W: Y
- final int newLight = convertLight(6);
, m* K# t: q8 f2 }7 P8 p- K - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
! G1 ~. a! ?4 [ q" V - final float lineHeightSmall = (y2 - y1);
5 ~) h8 K# o$ j/ k( \! c) ` - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);3 a: s" @' N" z) S' X" E
- pose.popPose();3 n. t5 a3 D9 B: A* ?3 [% n
- }: l* W3 k3 m7 p0 Z" Z7 c- B5 {
) u4 Y' H i0 B" D2 D8 F- private RenderType getLayers(String texture, int light) {
/ s+ Q; L1 C7 [ - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
+ L' ~* U+ `+ a) b: H- Y - }% D1 a4 h2 K: y k& `% b
- ' t, P. Y& p- r- E% Q: T
- private RenderType getLightTexture(ResourceLocation texture) { p# ]1 g+ ~9 E& t( `/ I2 K
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
$ v- y: l" ?/ t | C - }
4 x9 C; p6 U+ @3 A5 N
, u; _5 x- C6 D4 m: Z* @/ J6 y- private RenderType getTexture(ResourceLocation texture) {3 z1 Q* x4 u4 ?6 e7 }
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);4 a, ?1 { H# _5 e9 N; @
- }
! |% c& Z# b4 h4 S- |# b - , t: R, a0 u% l, Y5 F6 {7 L
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
' l/ {- B4 q& c# r6 i9 T - if (cache.containsKey(identifier)) {; p7 q' k) K+ r$ x9 A
- return cache.get(identifier);
' m) p1 U$ `( A7 m1 h9 a y - } else {
& ^8 l# V- o2 |; ^; }7 F4 M6 ` - final RenderType renderLayer = supplier.get();4 m4 M2 g* C8 u3 r: X9 M0 D
- cache.put(identifier, renderLayer);
$ A, \& ~7 Q! y2 w' z - return renderLayer;
, Q3 l7 K" m, Q5 P8 M. t - }
. a6 l- A9 a& |' h - }
5 `+ q7 F6 i% l2 c$ a2 @# m - }
复制代码 |
|