|
|
6 x1 @* ]) o! D) H0 @- Z, O7 O3 ^
行,这个怎么样
. O/ l6 K3 L F1 n) J6 p7 k- package com.xhg78999.mtrfac.render;( `! Y' k9 P6 A& k
- $ C( g4 A6 M% \6 H) g9 e
- import com.mojang.blaze3d.vertex.PoseStack;; R. w7 s b, S3 k0 s/ y0 l
- import com.mojang.blaze3d.vertex.VertexConsumer;
5 C3 }0 h6 {. Y! } - import net.minecraft.client.renderer.RenderType;
& e. Q# C' @* L1 T! R D& n# b - import net.minecraft.resources.ResourceLocation;
: T( }. P% X/ i
. ]. p) u9 h2 |1 p% y5 t" r3 P) h- import java.util.*;( [% h+ ^/ g) G+ d& i: D
/ i! Z I$ l6 ]# h# _ @- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(* s+ U4 v) A& o2 \) \- I
- 5 X. J$ L! L+ Z+ B
- public class LineRender{ s6 v% v' {* h$ r/ u2 [) a! F; @
- private final PoseStack pose;& W/ I, z9 o+ z9 G/ p5 Y
- private final MultiBufferSource source;( w# t, c2 ^3 |* ]
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();( P0 g' l) T' H% b( M
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();+ e0 i. A" f0 z1 O+ @
- 4 `& a) e) j f0 _) V
* B# e- G& [! H* }5 i( v& }- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){* X) F2 J o6 ~# R8 L, j
- if(x1 == x2 && y1 == y2 && z1 == z2){5 n* e7 R$ L, m; K/ b
- return;
% u) S8 N* [3 v* ]! P - }
/ ?( C$ v [; ?. q - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
2 \8 L2 {/ o0 \6 b C1 R4 `$ k3 q - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
1 O4 o7 w( A+ O! a' D: m1 X - }
0 R/ ^; k) a3 F- {$ K - pose.pushPose();. p. O D+ P5 I% j' A& q( ^- B2 g
- final int newLight = convertLight(6);4 h' y" q" H+ A! u8 C
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
) N7 w8 W$ K, S* P: t' v6 C4 y5 i- G! M - final float lineHeightSmall = (y2 - y1);- U9 H7 I8 G. S8 _, v# F+ g1 K
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
: b6 H7 x1 u; _/ n - pose.popPose();
6 Y6 T* A$ ^; d( s' Q9 q0 _ - }
/ z% T' F$ J1 n2 X" s - / _4 l0 ^. L/ ~. j r6 n. s
- private RenderType getLayers(String texture, int light) {& w K& t5 F# k
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));% c- y" i8 o1 D- y/ K& d
- }
6 a) s4 F- H$ E* d" }
& g0 O& {& U+ X" M6 v" E8 I- E$ m- private RenderType getLightTexture(ResourceLocation texture) {
2 a" j. I) T; Q5 [ - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);+ t E. s6 |2 u+ v1 @# I5 {/ f6 M
- }
; n& k" A0 h7 | - # n# T, Q6 T Z/ ?* {
- private RenderType getTexture(ResourceLocation texture) {/ F: ` ~2 e' `
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
" O6 @) T' `; `7 i; W - }
+ `; r1 q7 G, Q+ g& \3 H1 O - 8 @! i' N1 D: z7 X
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {5 n# R4 M& e- L( h$ A0 h
- if (cache.containsKey(identifier)) {
7 j! _: |$ n" W% G. A6 e( j - return cache.get(identifier);
% C/ M$ j6 X: D2 H - } else {
J2 I$ `$ o6 K; g- L - final RenderType renderLayer = supplier.get();
4 G6 C4 C* p4 }/ f) ` - cache.put(identifier, renderLayer);+ Z7 L) g# |+ p* H. D1 N
- return renderLayer;" h: Y* x% f: P/ Z% [% S# @) q
- }
* h. X% X- f" X2 _* A7 b - }
0 I5 I9 r1 {! K7 d5 t* }* y - }
复制代码 |
|