|
|
" o* W H# T' Z" y
行,这个怎么样
- N% r+ m5 r! R! d) T# i. H- package com.xhg78999.mtrfac.render;5 m9 L5 z1 F( t/ S. m+ y
3 P& P2 w6 I% J5 F6 M4 U- import com.mojang.blaze3d.vertex.PoseStack;
7 r) n+ C: R- k, G" [6 T - import com.mojang.blaze3d.vertex.VertexConsumer;4 D3 K0 n9 n3 ^
- import net.minecraft.client.renderer.RenderType;
* V9 n }. d! w2 g1 |/ A. ~5 C - import net.minecraft.resources.ResourceLocation;
6 C) w& P4 T% v' W+ O& y# ^% m
! B3 | j3 r6 ^6 e- import java.util.*;3 o$ @' _! ~6 \7 |
- * Z* E6 D; M6 G( {2 ~
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
9 s/ y% c+ j" |+ P
% e; Q0 V' a( U- B- public class LineRender{
" S! H e% q$ E" O( ?, _ - private final PoseStack pose;( l$ P# n% t% d% f/ u/ ~$ L: F6 S
- private final MultiBufferSource source;2 `, X7 K$ S2 \+ `
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();& o/ g9 B: C% r
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();+ }; l1 x2 a [- b8 r, r, ?
) T& w, D$ {1 o4 g- 8 ?$ W' Q( ^1 U/ z: |- i3 R) _( Z
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
. v* o/ a+ ^) ^9 w5 H) k - if(x1 == x2 && y1 == y2 && z1 == z2){% F5 U1 m, q9 s- B" ^# u: j
- return;3 U' f- f. Y X
- }
( p# B, N% g2 s$ m$ m/ N0 i5 ~ - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
5 I5 V [ N3 c1 { - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");: ]# i% h& g1 N3 \ Q
- }' w+ L- Q P# w& }6 G% E3 @
- pose.pushPose();& L3 F( @+ R/ j6 \( T
- final int newLight = convertLight(6);7 V1 S5 C. X6 w6 M" @
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
0 m: l. J4 j5 b! Z& r3 S' t - final float lineHeightSmall = (y2 - y1);
! C1 J+ ?' l2 b5 a& ` - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);2 I" z" B( c& e x Y2 J
- pose.popPose();, V" k- V0 W9 y2 y) S, b% C4 V
- }! X4 @# }! N/ V( K6 x: Y
& U0 I0 E9 V- A o: H; s5 I- private RenderType getLayers(String texture, int light) {
4 n, ?6 n/ R% `+ r - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));$ C1 n' M3 G# j; |, r# W2 t
- }. T z1 W3 P0 Q( ~) d( J& V) `
- $ M6 y# w" }5 r- y [ h5 ]3 G4 h
- private RenderType getLightTexture(ResourceLocation texture) {
0 h+ l1 q3 e2 w - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
. B' w n* E, d- O5 M- L- u - }
1 M3 i/ ]# N! a! @" {6 U
% |" X2 ~4 `- }# E4 ^- private RenderType getTexture(ResourceLocation texture) {5 d- v, W1 a' d _
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
0 x: E4 O/ f9 u0 _. B! ] - }
9 h+ p) f2 ` g% L T9 Y& J - $ J( R. @0 C( W. A$ r
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
3 }% n/ }& C! Z6 I- A - if (cache.containsKey(identifier)) {1 O I) g3 i4 A* T! L. k3 R& w
- return cache.get(identifier);6 j! _! v6 @5 o4 N2 M
- } else {
4 O* C- \9 z! ~; B% n+ z+ {- Q - final RenderType renderLayer = supplier.get();
5 r! V$ [7 o$ z- s- y' X - cache.put(identifier, renderLayer);% e$ P" E3 j& M
- return renderLayer;
. O8 T) Z: x+ V3 n, v - }
6 n+ ?/ `" K ~, \; g) I' y - }/ E# }- c% G1 N8 l, W
- }
复制代码 |
|