|
|
) s1 ^) p1 j4 m& j行,这个怎么样+ F4 A" [! D: N1 o9 D% \9 E9 Y! \! L
- package com.xhg78999.mtrfac.render;
& v" v( C: V. Z
2 l% `7 M. M3 G6 G) c- import com.mojang.blaze3d.vertex.PoseStack;) Z4 A; |1 f9 Q+ H
- import com.mojang.blaze3d.vertex.VertexConsumer;0 X2 d' c5 h: b* H; H s* M" ~
- import net.minecraft.client.renderer.RenderType;: e! U' t- d1 C8 X
- import net.minecraft.resources.ResourceLocation;, u/ Q0 [0 ~- L3 j; J
- * C# c9 }$ P( k1 ]8 s4 N
- import java.util.*;
1 h# L! ], ?+ e3 ^: B/ C
[: ^! `* t) Z; j( B6 _0 P- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(1 \4 C& \6 ~$ D9 ?5 b; W: I
- ' s, J1 M$ ` F' G
- public class LineRender{
2 E4 c6 k+ ^$ ?( g& W - private final PoseStack pose;
9 p4 J9 ^1 E6 r. C6 G - private final MultiBufferSource source;
0 M" g; F% e5 h0 I0 R - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
! u, P7 Y* m" q2 W6 S% l - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();) _8 Z+ ^' v6 H% x/ Y2 E2 y1 t4 }2 Q
& ~9 w5 u5 j1 u% G4 j4 n9 E- N. b! H5 j( a" c% \
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
2 U: ] ~$ _ d2 m - if(x1 == x2 && y1 == y2 && z1 == z2){5 o/ A+ e7 W; \% r
- return; R% K0 a; ]3 ^9 V
- }1 J, {+ E. F* H7 k7 b
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){# p) S. h& V, K7 Z- v$ b" n
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");: ~7 ^; N& p; Y, |+ p/ C
- }
[) e0 B- d8 I* f+ ^% z - pose.pushPose();
& t1 B7 J+ a& L! a2 Y' `' k - final int newLight = convertLight(6);" Y5 }$ K# _$ `) Q5 C o
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
* N" `6 t7 G- V0 M2 k( e& ^, _ - final float lineHeightSmall = (y2 - y1);$ m/ l8 l: |4 u
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);3 ]4 ?' t& H+ h" b7 {
- pose.popPose();9 |* a9 g. J9 s' D
- }
( `4 Y# {* z/ f! p# L
) `/ W. v/ b4 O; |/ ~! r2 a- private RenderType getLayers(String texture, int light) {
5 d- Q. v3 {; m& Q4 V7 V v - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
" p( E- p' c% I; A2 h - }! q' N( u; N8 ~; _0 k! d ~1 l1 ?- O
- 1 h7 l" r2 `) B; n4 I9 A B
- private RenderType getLightTexture(ResourceLocation texture) {
4 }% e6 q2 \8 d: S/ ]; y; [ - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
# X* X* d( T: F. g! L - }
- ?: Y( G0 e/ R7 ?0 w - $ Q! L. ]$ k5 [% ~+ G
- private RenderType getTexture(ResourceLocation texture) {' r% R3 z* @# f9 o8 C1 a/ Y' x
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
6 T& l; S+ _, L3 K, }3 X0 k - }
/ k" Q: I% T* \" P3 o
0 h& ?1 c4 \" J2 H0 l- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
; J5 \% u) S, t q+ L; K - if (cache.containsKey(identifier)) {
/ Z, }7 i/ w" \- N- S) z# K - return cache.get(identifier);
) n& r* G& N1 u - } else {' F* k `, ^+ u
- final RenderType renderLayer = supplier.get();% ~$ u' x" N( J: |3 s
- cache.put(identifier, renderLayer);6 r9 e3 `9 }( Y6 w. c
- return renderLayer;: m9 D# z4 K, M6 H9 C
- }2 a& l! c$ ]" C7 E4 @$ j
- }
[; S, r1 b3 g! B J - }
复制代码 |
|