|
|
& K- ?) e: _$ s; _
行,这个怎么样
1 q8 J& }/ ]& A2 U/ S- package com.xhg78999.mtrfac.render;
8 W' G1 |/ w1 [0 `9 M$ D. h$ `
7 c4 n6 e. {4 O9 V2 S# t7 B# y% y4 v- import com.mojang.blaze3d.vertex.PoseStack;
3 o- ^0 {" |" x/ c, D4 } - import com.mojang.blaze3d.vertex.VertexConsumer;% G; ]+ I3 u( \
- import net.minecraft.client.renderer.RenderType;8 x. T) m1 d4 L% Q: q$ W3 X. X7 M% b" E6 H
- import net.minecraft.resources.ResourceLocation;( [; o; G5 ]# ~. F
- # b6 f2 F1 W5 u: @7 `
- import java.util.*;
! M5 ^! Y; B$ x. }4 \9 e; n6 u e - 5 x8 N0 L O; v+ S0 k/ C7 Y$ V4 w
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(, f+ @) E9 T* V% ^+ c6 S! ~
- 5 d" s1 K% h3 N7 D7 Z. m' Q# \
- public class LineRender{
0 y8 W _1 m* e2 `3 Y - private final PoseStack pose;
' ` [7 j& p& d4 S+ x - private final MultiBufferSource source;/ X7 G! d/ y& C' Z1 B# b) X
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();1 |0 n$ ? I) ^9 E' |
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();0 U M6 t, C# v$ [+ a
$ r$ ? V0 L/ s7 R8 |8 }. j- 3 Y5 d7 { h, ^4 v( Q
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){' `: l$ ], d1 U
- if(x1 == x2 && y1 == y2 && z1 == z2){
: O, m" ~* A9 w% K, S5 p - return;8 `+ Y/ E: C6 E4 O
- }" p8 s. m: T2 n
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
1 Q: x* d: L9 S2 y - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");7 ^% |8 p+ P& b* B' u( o
- }
& }# p* z: e' O. M - pose.pushPose();& e9 s; K8 ^4 R; `; Q% Z
- final int newLight = convertLight(6);
& m8 f+ D1 G! c" T3 H3 k1 I* c: Z+ ? - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
2 n6 Z8 C0 B! K4 l' e - final float lineHeightSmall = (y2 - y1);# p9 S/ p' u" X
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);2 e* y- W$ k' P+ S5 b0 `
- pose.popPose();
9 h* Z) l& l+ v - }) F* g# Q" j) f
- ; y& w3 g9 G- I! T# p0 T' R
- private RenderType getLayers(String texture, int light) {9 \) j* F# |2 w/ A( f$ P g. w( J
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
0 f! m/ ^, y/ \8 l - }7 {0 ~1 ]. ]) [" Y2 I
+ `- e1 x3 }$ X" Z. o- private RenderType getLightTexture(ResourceLocation texture) {
1 A0 H' N- R8 J _0 K L - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);& y' R. {' }7 o/ a5 [5 i
- }
& b. e; L6 r. K- y- y - $ N$ a! P$ {- Q" s6 U& ~0 ~* V' h
- private RenderType getTexture(ResourceLocation texture) {9 q+ B$ w7 A' M
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);+ \; @; Y" H( c6 z: Q2 h6 H
- }# U& G9 P, }; p
- 7 V# C4 _( u6 _" D
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
! m5 o5 u2 ~. m( ~- w. E7 x - if (cache.containsKey(identifier)) {9 g2 @: M" E4 C; ^2 z
- return cache.get(identifier);
( [2 Z8 [' Z, y9 H - } else {1 _( x$ M/ r/ d) ?0 C" s) t+ t3 Z
- final RenderType renderLayer = supplier.get();
' R& q* A. Y/ y - cache.put(identifier, renderLayer);
+ }: T7 O2 g$ e, j. D5 S - return renderLayer;
0 o6 v! H w1 d s - }
n1 F+ x/ U0 y$ ? - }
5 G* z; ]3 y4 Q - }
复制代码 |
|