|
|
: Q. V5 @% R; w5 o0 T+ L
行,这个怎么样
1 U1 J& |5 E: i6 B `- package com.xhg78999.mtrfac.render;
$ b! @! O" F7 V: o - . r$ M$ k) @* s, J
- import com.mojang.blaze3d.vertex.PoseStack;. O* y J1 }- L( w
- import com.mojang.blaze3d.vertex.VertexConsumer;
4 p( g) \, y r) s4 O, ? - import net.minecraft.client.renderer.RenderType;% P6 }* c- ?& l" Y) S4 B1 i
- import net.minecraft.resources.ResourceLocation;$ U. w: `" ^! i. r& ~ m
- , p+ N: g" J. i" J' p6 R; @: s
- import java.util.*;5 U) o1 p2 O4 B+ ?) y2 r5 h) E) b) `' I
) Q5 H) B& K% S- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(# R" n- W, Y% ]2 N+ c$ [
- ! S, |* P) @2 t6 t9 |! V/ V4 y7 Z @( n
- public class LineRender{$ C9 D( |7 D/ o3 j: n* ~" C
- private final PoseStack pose;+ _5 S/ p6 p& V1 l; T* E! m
- private final MultiBufferSource source;) D# j+ p# Y) n' B, ]& M6 M
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();: J1 f5 b8 K) m7 W9 c; U
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
1 X: `! p% `! [' O- Z - 1 c5 m; A' e* W9 t ?
- ' w( D0 q4 U7 t
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
. H" f$ A4 _2 J" V' ?9 Q - if(x1 == x2 && y1 == y2 && z1 == z2){! }: I: p3 p3 Z$ N0 y+ E' O" S# @
- return;
+ O0 k: L/ h1 N - }
: q: F! q/ h- v' \6 h! f' C, G - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){( q9 E! k1 U# ?) o6 I( o
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");. u1 k5 ] _- K. o8 R
- }8 w$ z7 U) S3 T
- pose.pushPose();
7 ]9 v3 \: S+ L% c6 Y; i- C7 F- Y - final int newLight = convertLight(6);
2 H: J% ?& w. D - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));0 R( ^8 H8 |, K+ M3 w
- final float lineHeightSmall = (y2 - y1);, ^7 [( i2 \$ |7 ?& J
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
6 ~0 I! t8 O7 E0 E9 \ - pose.popPose();
U1 b* r6 v& @# y1 j$ @/ N# `4 i - }4 {8 Z0 V w% Y8 E, ^
: m# P+ G7 f# f# {9 ~- private RenderType getLayers(String texture, int light) {: D: Y1 X* P, Z
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
' _8 P' l5 A) v- ]0 c2 I! S - }* h, `- r: _, A* G, b
& O, E2 f6 }3 l) Y1 ^) @- private RenderType getLightTexture(ResourceLocation texture) {1 U3 P. e, Y4 m0 I; Z
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A); a6 G/ z& ]+ T. k& I* Y4 b
- }( O% M" W6 }* k& w. J8 ^7 z' N0 h. o
7 b- p8 D2 {& F( r- private RenderType getTexture(ResourceLocation texture) {! V+ z% p3 Q7 p2 k0 l: p
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
# O+ e+ S% H. W' m$ A - }
0 S- v: b/ o" J. m* D* p
3 N w) B1 ~% V. K& }( R- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
* g ~8 D2 B, @+ u - if (cache.containsKey(identifier)) { k. J( l8 N) _3 B9 C: Z
- return cache.get(identifier);+ W! X! ^0 @8 T) @
- } else {
n0 \: n/ m2 n2 k5 V2 M - final RenderType renderLayer = supplier.get();- v, I; k, X! |+ g/ E4 }
- cache.put(identifier, renderLayer);, `; j0 I, P9 t W- M
- return renderLayer;7 m7 I' a. c$ ?/ {* w9 s
- }
! y8 t/ V# H |8 g. b2 D4 Z - }/ N% I8 }3 a3 N- y
- }
复制代码 |
|