|
|
9 t4 z' ~1 p+ n% K$ _
行,这个怎么样1 B5 }6 z o% b+ e' Y/ y9 `! @
- package com.xhg78999.mtrfac.render;9 `% n& h0 ?, x2 y
, l% m& t1 t( G- V- import com.mojang.blaze3d.vertex.PoseStack;7 Z) ?( a9 r5 E7 d1 B
- import com.mojang.blaze3d.vertex.VertexConsumer;/ {* [2 v& f* {
- import net.minecraft.client.renderer.RenderType;9 `+ B" Q6 ?$ i. s. g
- import net.minecraft.resources.ResourceLocation;
0 v. b4 f7 t* J3 J' N L- `) A' @$ i - % B. e f& s5 D! C* y
- import java.util.*;0 p$ s/ F& x k( n5 U. d2 ]6 H L6 O
- 6 _1 U3 \: ^/ Q
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
/ w* S2 K i- [+ V+ O1 B - ! Q$ R; }) z7 a; e( n& s
- public class LineRender{
, O! q4 ^4 j1 F - private final PoseStack pose;! j- k" H, z. N+ m3 {" n) i$ [
- private final MultiBufferSource source;& ?+ X' D& c% }, i3 u% P" O, X
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();% [0 _' C% z1 [1 Q0 S( q2 k. Z! r
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();* T) L4 f, U& T
. L9 E+ M! {! z$ o- @! ]& M# r; v3 E5 Y# J6 L, l
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){" F% O/ r/ s0 [: r' V* L; @3 i
- if(x1 == x2 && y1 == y2 && z1 == z2){
$ ]8 i! i. M( | - return;
% t8 F7 T9 h# L* }9 o2 m - }
' e4 d* _; S8 Y4 ~ ]& | - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){0 Y' T/ j) b& n4 g6 A( N/ c! I: q
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");; A; p B5 T# U
- }0 d' N, j7 v j0 J
- pose.pushPose();
7 R/ Y" `; ^3 Y6 {% r - final int newLight = convertLight(6);
9 H1 f- e r$ @. u; k; G5 [2 ~ - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));5 Q5 |$ m6 P3 n
- final float lineHeightSmall = (y2 - y1);
5 w9 f) j' ~9 x1 T# V7 [ - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);8 [1 J0 ?3 U3 D' a$ ~7 r l' R. I
- pose.popPose();, y- W2 H1 o% \6 J% ?' O, L0 N
- }
( Y `0 W1 |+ X - ' ]7 w! H) N# k- ?; {6 c
- private RenderType getLayers(String texture, int light) {! [' b$ u& a" M P2 m
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));0 \, k/ w! } P# X& ]1 L
- }
) Z+ q5 n3 h9 \" Z p' X
# `4 T; f) S: c3 J. {- private RenderType getLightTexture(ResourceLocation texture) {/ ~/ `( E/ y2 @# J' j' f
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
' [; b4 e( L& C, F( w+ N - }& d4 ]( i* p! \8 r
- 0 ^3 h3 q! t! ?7 O0 `: @% E
- private RenderType getTexture(ResourceLocation texture) {2 e8 t0 g" W% B* G2 m! p
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
) x2 i% l/ } j& {" z+ M/ r& e4 d - }
- E+ t- n: f- r# p% @
! C- @7 g, o- i! P! _- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {2 ?6 K( Y' \. ]9 o% u; v" U* x
- if (cache.containsKey(identifier)) {, F+ p/ V3 p( M+ ~# U
- return cache.get(identifier);
' i O* b; E8 ]. Z - } else {9 q! [/ x# y T7 j! m+ Z& d: c% a4 X7 N
- final RenderType renderLayer = supplier.get();0 z8 K' R! E. s" U4 ~8 h) N" |: @
- cache.put(identifier, renderLayer);
9 I1 U, q$ s. S( A - return renderLayer;
" X. G& r2 _1 W) f - }
) x2 {6 [7 ]) ^1 _5 D% R - }
/ d+ c' j! [; u) O0 a& i$ D - }
复制代码 |
|