|
|
5 }8 h; o4 R" m: n: V% l
行,这个怎么样
! R- g" r7 o V* ^2 ?: _- package com.xhg78999.mtrfac.render;+ s% W1 D$ d" C" }1 X
4 N: h6 f* M" x" ]' Y/ N& A, @- import com.mojang.blaze3d.vertex.PoseStack;. W$ @) H1 y0 j
- import com.mojang.blaze3d.vertex.VertexConsumer;
7 m; O- y9 h- |, B1 r* P# O - import net.minecraft.client.renderer.RenderType;
. ~: O" R# Y3 Q$ N& G" } - import net.minecraft.resources.ResourceLocation;9 t, g' Z8 l0 b6 |
. Q6 ~5 M. w2 a5 B; H: L; w- import java.util.*;& C: V( R6 x+ M3 V1 M4 K! x
- 1 x) D$ O1 N! X. r4 m
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(0 C' e/ J& f$ U2 Q/ O
. P: j0 Q$ Z: l' H) r7 J8 J( Q; [- public class LineRender{( u6 o: k) t, H: C, O
- private final PoseStack pose;
4 a: E8 r y6 s" l - private final MultiBufferSource source;
. P/ R/ q2 x- z% n- Z6 J# o - private static final Map<String, RenderType> CACHE_A = new HashMap<>();9 |" T7 i V+ A' d% o
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
0 Z) G1 P8 _! n b, Y& B
: \" E r3 R' p- r: s3 }- ; I0 e% n( P0 i5 T1 D4 ]. n; r
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
$ a) _- A9 L# [ - if(x1 == x2 && y1 == y2 && z1 == z2){
8 j9 P! T2 v) i# |. _ - return;
" W: ~. @% }/ c$ o4 h& @ - }
1 Q7 ^( [4 _) K/ }! S4 H- l - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){ B! |7 n' n: y1 W1 V2 H) u! A# W
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");2 x$ N. q' L3 o' B
- }
4 W6 f# f' s) E" l1 P2 I, J - pose.pushPose();
- [+ u3 v# `3 i. Q. b5 k6 k - final int newLight = convertLight(6);
) C+ P0 A9 h/ k+ B1 W: k - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
: n1 ]3 v2 _+ q - final float lineHeightSmall = (y2 - y1);: ?: O% r( ]" G
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);; B* X+ R9 s# j7 B
- pose.popPose();. A+ g) }* Q3 }1 z
- }
: [3 @! k. u/ r9 o; u' m
9 u, k' R+ z0 Z" |) ~- private RenderType getLayers(String texture, int light) {
$ J% ?% Z# x+ R, r2 [ - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));; }& W& S( V. K1 R1 `3 a7 p
- }5 j) d, e* l1 e Y: i7 u4 s+ Q
8 k3 k; N! D# s. W- }; r- private RenderType getLightTexture(ResourceLocation texture) {
1 j+ D2 c0 Z) p/ ` - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);8 i3 P6 c; q8 z* `0 \2 x
- }
* T) }; g; f, Z8 v( l
& b# ` o7 j4 Y3 f- private RenderType getTexture(ResourceLocation texture) {! @* }, c* ^: x8 O, U2 Y
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
2 {1 V2 [. s, o- a2 B4 J - }8 |, }# _1 g5 I2 q* d7 x$ k/ U s
2 H) W% N. N8 v& L5 G9 n* I- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {9 K8 b) ?4 {/ B- y, y. C) s# k, U
- if (cache.containsKey(identifier)) {
( Q h: O1 U* c" t, o" ?1 K0 s - return cache.get(identifier);
) h0 t' b! B, Y7 j0 B - } else {
, S: ^1 d5 G& L5 S2 Y/ D* p - final RenderType renderLayer = supplier.get();
( p$ {2 g& s5 B6 E9 Y) p+ D - cache.put(identifier, renderLayer);! A2 V. T+ T* i; ?( a
- return renderLayer;! A! i! y8 B/ C7 t8 a O4 i
- }' R6 f- ~ ` B
- }
& `& {* ]$ t# E9 k - }
复制代码 |
|