|
|
$ R9 G: A1 u3 ~' r1 |
行,这个怎么样0 K# _1 G" o+ B
- package com.xhg78999.mtrfac.render;
- o" F& j6 a& }( ~* ] - 8 A* V# J0 P. E# _+ o' l' O. b1 g
- import com.mojang.blaze3d.vertex.PoseStack;
+ J: S, v/ E# \( @9 X7 N - import com.mojang.blaze3d.vertex.VertexConsumer;
: f7 j# M0 v2 L- D _2 q - import net.minecraft.client.renderer.RenderType;
. Y& i; a+ U# } - import net.minecraft.resources.ResourceLocation;
3 S6 \, Q- Q" O7 V, a* f: _
: I' z5 C2 i' d C- import java.util.*;
/ ?4 C0 @5 K# a7 {7 M6 I; ~3 T, m& r
& B( `; _. |( ?6 S& a- @6 e- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
) g g. ~6 H, E( O
5 a/ N' J# R+ {2 R1 R0 Y% c( D- public class LineRender{2 L! t" v1 e1 k& P
- private final PoseStack pose;
9 }. o1 M0 J8 S7 G0 g' a - private final MultiBufferSource source; j6 F" ]! R. h& g
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
: B5 Q) L0 F. g3 d - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();/ X; A* m3 [9 E
- 8 }9 l6 w; A5 y7 S
+ ` h$ W" n7 `: o; G2 @- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
( t K5 @8 Q& M6 W3 s - if(x1 == x2 && y1 == y2 && z1 == z2){! A4 N+ \: k1 h; x3 e4 Z! q) ?( C
- return;
* E& Y; v3 A5 ~ d8 J: r$ y - }
) K$ V- o& K: L4 `* ~ - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
5 s- S7 \9 z0 k+ H - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");) P# D4 m3 N* @
- }
' x$ D! a! W" N! a; t' Y - pose.pushPose();9 o- h! Z7 ^- M8 } J! k
- final int newLight = convertLight(6);
! h2 t/ T& R* g3 a; ^- E- [ - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
* C# c! M, i" g; Z" Z - final float lineHeightSmall = (y2 - y1);% P0 W, T/ ^4 v+ y* E$ `
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);8 O2 A: M$ r* W3 P- W y( F
- pose.popPose();
' d7 O# a* ]/ X9 m# b' q# \* c% r - }
9 _# f* O) N" i' j6 X/ _* I
5 p/ T. v# }+ {+ J1 ~- private RenderType getLayers(String texture, int light) {% h: o: R' Q/ ?+ ~3 M) Z5 Z
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));+ m& X* i& R& E# p4 W
- }
- D2 S/ y9 H) l3 }$ y4 T2 b/ X
/ e4 h+ C; t. S6 I- private RenderType getLightTexture(ResourceLocation texture) {
7 t8 N% Z7 S# p1 f9 m9 m - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);' D8 O4 Q1 J; G0 ]8 b' C: P
- }
8 I& |; a. D) u, v: X& E, T
: Q8 h" u2 H- }: P4 c" y3 _# A; h- private RenderType getTexture(ResourceLocation texture) {# q+ |# p0 K4 V; S6 z1 E8 p8 C
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
" e& X7 r5 f9 h - }; V2 G2 ]. t6 _
- $ s. p& h" `( N* ]1 i7 R" u9 w
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {: P0 C8 Z; Q: T6 t" [
- if (cache.containsKey(identifier)) {+ Z* v% [- \8 {2 D8 [, I. C$ B
- return cache.get(identifier);
) K' D/ d2 z# b# d0 | - } else {: n) | u! k; g# J3 x/ P
- final RenderType renderLayer = supplier.get();
4 w/ |- R# V$ @0 k+ r6 I8 ?; o - cache.put(identifier, renderLayer);: c+ e" U8 {4 k& B+ [# [* R
- return renderLayer;
/ ^5 t, z; i7 ]0 Q( n8 w - }
! R" N8 i' R# z0 w4 `+ r- t# P - }
' c6 A; R" q8 f' d8 o( C - }
复制代码 |
|