|
|
7 l8 A, z+ i5 k# Y$ ~# f3 p9 M行,这个怎么样/ D. H& c1 n1 K- o0 d$ K3 u
- package com.xhg78999.mtrfac.render;
' t8 I' B; E! i/ x* Y. L* w" F7 T2 T: G - $ h9 J" |8 p2 x. _+ \+ |
- import com.mojang.blaze3d.vertex.PoseStack;& |2 n) {8 n" r; M7 l
- import com.mojang.blaze3d.vertex.VertexConsumer;( m* ^" a- G, {+ p% ~
- import net.minecraft.client.renderer.RenderType;& q" l0 L5 S1 {
- import net.minecraft.resources.ResourceLocation;8 @- u) O' w2 b, J( R
9 K6 T: d& V) o2 d! f/ \- \3 g& l$ u$ d- import java.util.*;0 o, S# E/ ?! h4 D
- % L# q* J! D2 ]" P' q
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(2 f' i6 v# V: h7 C" x$ z. M
- 2 y" E1 l6 q E/ T y4 O, G
- public class LineRender{
6 p4 F$ @) C$ T; q4 } - private final PoseStack pose;5 p8 ^2 e% }5 ], B0 @2 Q6 i
- private final MultiBufferSource source;
* x# ]6 m7 b5 \ - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
4 P; G5 Z0 j" G" a1 x+ i' t - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();& D. ^) ~+ T' I. ?- A
- & }, W" I( [" _
5 R: G. G$ \5 V N( C% N- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
; p% e( P* n# S* s; ?- m$ g - if(x1 == x2 && y1 == y2 && z1 == z2){
0 m, k! v" {8 L P - return;
; M9 K" Z' U2 S+ D7 C5 ?3 P9 i5 |8 }6 ] - }
$ X& ^) {5 A: X6 M( A( _0 i7 `' L - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){9 p' {* K7 a$ `1 e% g
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");9 ~; e1 c7 a0 ^
- }
2 n8 A( S# a' E, b6 _8 o, V - pose.pushPose();
5 R5 O, \: n6 U: P# g - final int newLight = convertLight(6);
4 J) n0 w6 N+ P- N6 b - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
7 M: p! B3 a& ]" p: s- K, r - final float lineHeightSmall = (y2 - y1);
1 _2 d4 Y+ c" K$ q7 @ - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);7 E+ Y! q: \& v& F- y
- pose.popPose();6 G. v/ e9 E3 }
- }
9 |8 K, N/ \0 u
' I- L9 N5 j( T g' c: X- private RenderType getLayers(String texture, int light) {
5 O( `) W3 [9 g - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
7 u2 N' t- B8 N4 i7 _+ V - }6 L" N% B0 z1 Y2 C& S' s2 Q9 g! [) [) ^
- : N8 V; T3 k) i/ E* w
- private RenderType getLightTexture(ResourceLocation texture) {
% e2 V8 a2 n$ N6 T - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
; c6 E/ I3 ]% C/ O6 W* T( m - }, T+ x! [7 q! b4 H
& |# Q; q, W" a- private RenderType getTexture(ResourceLocation texture) {. c2 w$ D9 m0 y9 r) C& z
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);0 L( g4 N2 }' E; V; |
- }
: y- x5 K2 k7 @; m/ U- F$ j# I - 9 n7 k3 h P: T! z9 n
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {+ {* O G" O: f
- if (cache.containsKey(identifier)) {
4 t% i7 V. s4 F - return cache.get(identifier);) N" }9 m- w9 |- L! f; t9 S) E
- } else {
3 _1 C3 [1 k- P" z" }. Q - final RenderType renderLayer = supplier.get();* O2 Z/ a: o& L" S3 Q* {
- cache.put(identifier, renderLayer);3 w4 h% [) x6 [2 N6 i4 T' `6 L3 P8 z
- return renderLayer;+ b5 o$ ^: g0 q, b
- }
* B4 H J- p7 J' c5 F6 g0 H - }' c) w* D1 ~- U/ X& w) | V4 e) e( Y
- }
复制代码 |
|