|
|
! ?+ x! ~ z9 C9 _' ^" O' {行,这个怎么样
1 n$ o6 `, n! o- package com.xhg78999.mtrfac.render;0 z+ R g6 V3 C, n# G% d
" A" `* o5 \# _& f- import com.mojang.blaze3d.vertex.PoseStack;7 G( Q8 b f2 F+ n
- import com.mojang.blaze3d.vertex.VertexConsumer;
& ?" C" t+ ]% D) v1 R- @+ W8 N* }$ l - import net.minecraft.client.renderer.RenderType;/ n8 D2 h% w4 G6 K8 r5 ]3 ~
- import net.minecraft.resources.ResourceLocation;
: m( o- l" [9 s) f: C - + t& s" w# l6 `& `" j+ P. i, F' A' v
- import java.util.*;+ L7 X* |! E! W, k5 L, i
/ t# M5 w% k+ o( P" b* f- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(( F5 O/ i M* z. \4 D
- k e& S$ i: ]% H& g% L- T
- public class LineRender{ C' H( `# Y* b3 _+ E+ T
- private final PoseStack pose;
3 G0 O, P6 W# W% t - private final MultiBufferSource source;
3 E3 s9 d9 g4 f8 L6 s - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
8 c- _7 u, J7 R: u$ m. H - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();8 u8 M' ?6 d0 X4 d
- 9 j6 C0 c6 w! j
7 P! l/ k9 P( G- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){( ]* I: h7 C- d; a2 h N
- if(x1 == x2 && y1 == y2 && z1 == z2){# y( U: n+ S3 I/ i
- return;5 {8 G1 @" p" s0 ^8 f
- }
" x y4 A; V) x& ` - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){0 X- h: b5 h1 j! r, t/ _& {
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
7 G2 `( d, a& I( q4 |. ~) p) M - }6 _5 e( r: P. |, g i$ ~, X
- pose.pushPose();
4 x# j0 u1 ?' O4 q - final int newLight = convertLight(6);
! j) M; F" Z" `4 ^7 V# f6 [* h) G2 q - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));) n8 X% m' L( e- [* b
- final float lineHeightSmall = (y2 - y1);7 `1 A) V) _; z: v
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
3 W) X' a! G' ~4 A4 L# E B) E0 f - pose.popPose();
" e' K, c0 n2 S; r" b1 O% ` - }( }$ S) _4 ~% Q( T$ N# p
4 G* e- H" Y7 i$ p- private RenderType getLayers(String texture, int light) {* p0 r- i" }3 b' R) ^. f% v+ q3 l
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
! U( B0 |, n: j( v - }& n. E/ t3 ~9 k7 a2 g. y9 k
/ C+ ?, K' U7 A$ u8 Z. d- private RenderType getLightTexture(ResourceLocation texture) { T* V Z7 [0 i2 t
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
: ~9 U. @. p% s - }7 D' h& g" Q( D/ y2 ~6 Z
- D6 c# \2 G4 G# f- private RenderType getTexture(ResourceLocation texture) {
+ u8 H r; \# S% Z3 \; c+ ~+ u - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
( [9 E! [3 N" i9 D: F8 w - }8 [% _# Y9 _' B+ W4 m8 h
! k3 r$ S o1 a9 t- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {% u. M/ f/ e2 J1 v) }% _% Z9 v
- if (cache.containsKey(identifier)) {
# v, M" B. T+ f8 R1 I - return cache.get(identifier);6 C0 r( u, J4 S( x2 ]$ k e0 ~
- } else {
9 _( n" O9 v7 h& ^/ e% D& y6 ` - final RenderType renderLayer = supplier.get();
/ [8 o1 h+ t. Q - cache.put(identifier, renderLayer);; ]& P1 _9 T: H# R5 S
- return renderLayer;
]: I: I' n7 W& o$ J) ~5 ` - }* _7 Y8 V. B5 e0 p1 }
- }( ~ r: c9 [. A: m: _" O
- }
复制代码 |
|