|
|
A! s7 D& g5 g O
行,这个怎么样
. o v. x$ [/ L' t7 _' v, g- package com.xhg78999.mtrfac.render;5 x4 P" F% ?& T# T i
- - ~6 i1 S$ J/ M- I8 k% V- i
- import com.mojang.blaze3d.vertex.PoseStack;
: D2 y, t5 m3 z, f& c6 G( z& G - import com.mojang.blaze3d.vertex.VertexConsumer;# `+ f1 g1 J. x' j1 }; ~+ C- c
- import net.minecraft.client.renderer.RenderType;
! @2 u7 v3 z, w* o; q! q% M& O - import net.minecraft.resources.ResourceLocation;
. e2 P% ]/ R1 _- W L8 j/ Q% B - 0 G, V% c- H: B* R$ t
- import java.util.*;9 {7 l# g6 c6 j/ P
' Y# f. E; j/ K' ]2 @* h# s- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(( E5 A' v0 @2 B
- 4 W* k% T1 V$ I. r4 z/ S% l
- public class LineRender{) l. z- {- X8 d0 n
- private final PoseStack pose;; R4 {# \7 R3 F+ n
- private final MultiBufferSource source;
( A( d( D5 a; V2 K. j - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
* W0 [) z$ R# E( M$ Z - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();3 v5 H" h V- v6 ~" S* D
- 7 I7 d- l# t. A) t
* Z! {5 O3 {: p* {- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){8 Q4 n' R! Y0 {# a9 Z
- if(x1 == x2 && y1 == y2 && z1 == z2){
1 J2 ~' u4 Z- J% ? - return;" U. b) u: y$ r5 u7 Z
- }* B. L+ V5 T4 |& w4 t
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){" ^7 q6 Y: H7 o5 o
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");4 O- S, l! @5 I; J
- }. i. y) [; H! q0 a2 I0 i6 Z
- pose.pushPose();% `; D+ Y1 \2 l. r" ^# w
- final int newLight = convertLight(6);
! R* A- o$ q+ y4 Q. |1 E - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
2 |: f1 m( p6 ~$ q9 M- w$ Y" k8 x - final float lineHeightSmall = (y2 - y1);% F: h, ?# Y |
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);/ Q9 P. j ^8 I* F9 Z2 P* ?( W
- pose.popPose();8 v/ @ ~5 G, o' ^5 @' a5 P
- }
1 Y8 Y3 U+ {# t! h3 l
5 U- @2 d6 f6 }1 ]' V" X' x2 ^5 {- private RenderType getLayers(String texture, int light) {: {8 T7 s3 d9 |7 C
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));) U# B. K0 x; z, q) }
- }6 r4 m. b0 G6 d2 }. q; V) Y6 }8 @9 p
- 1 n+ @% E. u3 o) q1 S3 K. m6 w: c
- private RenderType getLightTexture(ResourceLocation texture) {
5 h! `. M" X0 q% ?+ I - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
4 w$ ~! u; x0 i0 E# B - }
8 T7 [6 [7 P2 n( _ |$ M - : F2 A( b/ H# Y/ I+ o9 p0 m
- private RenderType getTexture(ResourceLocation texture) {
# q7 u$ _( U( R0 |* `) x4 ? - return this.cache(texture, () -> entityCutout(texture), CACHE_B);1 K! X! b" W- q+ x1 {+ N
- }
( I' o& Z. L3 e+ h) ~1 @
' j- W0 }% M" W- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
5 a" b0 B9 D- S1 F) u. Z) G - if (cache.containsKey(identifier)) {
4 _2 [. B6 P& `4 m - return cache.get(identifier);
8 p4 o ]. `5 I- [ - } else {
4 H& S; d7 y: X2 t0 L8 G X' B - final RenderType renderLayer = supplier.get();$ [0 s: N& I+ [% _7 c8 _
- cache.put(identifier, renderLayer);+ }# E* X L+ F) H; X! l: `
- return renderLayer;) W! P' B9 d7 R
- }
' ]! `* x+ J8 G! u8 g - }) y$ j5 U( `( s( b& M; }# l
- }
复制代码 |
|