|
|
) ?1 p/ z0 ^' I5 `2 p* B2 {+ p4 ~$ T
行,这个怎么样, y3 e; B f1 y
- package com.xhg78999.mtrfac.render;
+ l6 @+ T# C/ l7 e6 ]! X- v/ B+ |
4 K6 q9 K& W$ Z3 B- import com.mojang.blaze3d.vertex.PoseStack;
- [3 J' _9 G! x8 _" a - import com.mojang.blaze3d.vertex.VertexConsumer;/ ?8 {6 j& h8 Y& K# `
- import net.minecraft.client.renderer.RenderType;
1 R5 `" I8 u8 P# j) f - import net.minecraft.resources.ResourceLocation;7 q: @- P9 H6 Y0 p' ?( F7 @
- 5 l; R3 C# h0 J, |+ N) l4 H9 F
- import java.util.*;+ j7 E: `7 r+ c% q
6 s8 s- U1 F$ i$ C( {: \- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
f2 ~& w' B5 i' a - . M( ~& j9 v% ?7 h% m) V
- public class LineRender{
& n" E* g a2 @ - private final PoseStack pose;" u' A/ w- [3 a
- private final MultiBufferSource source;
! T+ y3 y( m( e - private static final Map<String, RenderType> CACHE_A = new HashMap<>();" I% S# l5 G( F( M R2 P4 T" a
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();3 i0 y: i. K/ Q7 Z4 K( Y, l q
( n) h8 o3 ?9 E8 i# I, a6 q; k
! j9 q' M5 D( \8 ~# t+ Z+ p- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){6 r* s! `! b% A% f+ ^6 q z
- if(x1 == x2 && y1 == y2 && z1 == z2){
$ H; H1 a. j6 E - return;
! x- p/ p) \) D. `+ D9 M# s - }4 i" b( x) }& |# ~% G2 p
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
& r$ p* A; l' M" Q/ i - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");+ h9 U2 L, H1 X% ~7 k
- }& c0 p$ G6 A3 O2 L6 D# W2 t5 _
- pose.pushPose();! m6 v+ R, w3 j# r
- final int newLight = convertLight(6);3 x3 n: \- }, l0 U: @7 q
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
2 j. j3 n0 C/ H3 e8 D8 F# h" v - final float lineHeightSmall = (y2 - y1);% O- c$ P; h. @+ x2 b8 _
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
4 ^8 y' Q' D$ O5 v' U3 W - pose.popPose();
' B5 H P I& w! Z0 T9 ^/ b - }; n. _3 @, g2 Q! i
2 D* |8 V! O+ X0 Z/ l4 S- private RenderType getLayers(String texture, int light) {8 U( J6 x4 N3 r y+ ~ J& O! w; O6 z
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
9 h; ?& P! u0 X/ ?9 Y - }
) e: u" T/ O$ Q9 I5 P5 D: h - 0 Q' P F& y) t9 g; y4 j
- private RenderType getLightTexture(ResourceLocation texture) {
, E/ w, b9 w5 N4 N- y - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);! f$ T* \' L, [: p' v8 ^0 [ ^
- }7 q- |/ z( O8 w& P) }) H6 j
4 [2 C' w9 L2 Y- private RenderType getTexture(ResourceLocation texture) {
7 B/ {( W4 ]% T0 D - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
4 n8 `, @3 B) j$ h( B - }. t7 V9 f* X( X! w$ H$ c
2 H( O$ Q0 {( f7 w2 }$ |- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {2 v5 j/ Q& R- D* r" y* j# ~
- if (cache.containsKey(identifier)) {0 k, J: x% }1 B: C/ E4 N' z
- return cache.get(identifier);
0 _1 |& G8 t. r8 f& }( |$ h - } else {4 A2 {% x2 a1 X: n" Y2 j' s# z
- final RenderType renderLayer = supplier.get();5 y5 ] @1 N3 t
- cache.put(identifier, renderLayer);: F% D% o( v: h6 F- B) m; M- w
- return renderLayer;
! w* ?$ [$ X! Q6 o; ? - }# |6 J3 \9 A7 G3 b; @/ `6 F
- }
: q; M. ?" L' B. k% u - }
复制代码 |
|