|
|
; Y" Z* D$ S6 Q$ Q2 O- e: e( y: I4 t; m
行,这个怎么样+ u- w( o4 u" `( T* W/ R; [
- package com.xhg78999.mtrfac.render;0 _3 `1 U3 z0 n5 w' b$ r7 K
- 2 ]6 G, }: t% Z8 C
- import com.mojang.blaze3d.vertex.PoseStack;
0 e% n4 [/ q7 r3 b6 @, Q# i - import com.mojang.blaze3d.vertex.VertexConsumer;
) Y8 y2 A' |4 W5 O' s- r. X - import net.minecraft.client.renderer.RenderType;
# Q1 l1 ]/ Q) K% @6 g( C, ~ - import net.minecraft.resources.ResourceLocation;
: {- p7 ~# D) J - , m( ]$ R+ `* l6 O: `% Y" ?
- import java.util.*;) U- w/ n# |9 O3 d3 N
4 N8 z( t: s* ?. Q" D8 b; R4 |- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
. {# c% Z- K8 f Y O6 p - 1 D1 [- n5 j8 X [. y$ u$ h0 ~
- public class LineRender{
! i6 h+ G t: Z% L - private final PoseStack pose;7 u% ?1 ?. Z' S7 `* E1 c. i
- private final MultiBufferSource source;: v5 N) ~: \( p) I1 v
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();. P0 k3 R, y& A g! O' {
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
b: f7 W2 U1 \7 a; Y8 G* `) Q$ q* n: w - & V7 J3 r- h9 @
- j) P* y6 |! ]
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
, N- r" O6 [1 o! q/ R. ~% z - if(x1 == x2 && y1 == y2 && z1 == z2){
8 m8 c) d% `5 ~4 A - return;0 A$ w0 k0 _# D& P
- }5 u3 R0 p) ~: ^8 e6 D, [4 i! m# c1 |
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
! q A) V" [* f2 x4 k. A: u - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
4 r2 {6 ~: ] w4 B - }% n1 t* i% @7 M2 ]$ e; w
- pose.pushPose();+ y) m6 q6 w K
- final int newLight = convertLight(6);
. T# W) p" {( b5 y4 k+ q$ ] - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));1 z" B: A3 D' g
- final float lineHeightSmall = (y2 - y1);. ~$ l d, ?& F6 `' J! m
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
- b0 z$ k4 l: _- \1 H: i4 d - pose.popPose();: t) l. v, \2 m' {: m
- }; k7 z0 i1 Y; C- ?- L. U+ @
- + C5 Y0 v! _+ Y1 n, W; u
- private RenderType getLayers(String texture, int light) {' \; ?8 J: K8 ?+ `8 \9 K
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));! E5 K9 N" d0 ]' \4 f8 Y
- }
4 O1 H w; t2 D9 S& |5 E- z
7 R' T% f" A c) }5 H- private RenderType getLightTexture(ResourceLocation texture) {% D! k& a- D- L2 U" h
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
+ U* ?) t, C) `$ ]+ T" ] - }
+ }6 E0 t, q" i, O2 W4 L, k - 3 h _4 ~0 P8 t# m1 n: X4 X
- private RenderType getTexture(ResourceLocation texture) {
5 _) g, }( H8 q% `2 \$ |& r3 X - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
% V) r s: d, F5 ]5 A7 a/ f - }9 D w. w% f( t+ Q1 x9 W
- ) A9 i$ S4 R" X. ?! J" |3 C( x7 Z7 w
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {$ s1 W1 z* B3 C5 q$ C8 p
- if (cache.containsKey(identifier)) {; S& U7 h) w# y0 ]1 d A- O) {
- return cache.get(identifier);4 \& p$ Q/ j1 q9 C' n
- } else {
& D& K, [+ X5 H/ x1 _ - final RenderType renderLayer = supplier.get();" W/ z5 O2 P! b% h! B
- cache.put(identifier, renderLayer);; K- j2 v6 G$ w# h2 T' O' n0 T
- return renderLayer;
2 E# g$ b8 V0 }2 E - }
! M) i. f" @0 P - }
3 o9 f+ B' F' B' W9 p: E, r) y' s0 e- g - }
复制代码 |
|