|
|
5 E( Q2 _' c2 g1 R/ G B, ^* g
行,这个怎么样
) Y$ e& T2 ^4 H" ]5 s. M( [- package com.xhg78999.mtrfac.render;
5 \, C7 x# s$ f# Q2 w - 1 P1 o6 ^) ^$ w' J
- import com.mojang.blaze3d.vertex.PoseStack;
" D2 s* b- D8 A - import com.mojang.blaze3d.vertex.VertexConsumer;
8 F# x; _; |. @3 k4 g - import net.minecraft.client.renderer.RenderType;6 q$ [$ M& E4 E7 _
- import net.minecraft.resources.ResourceLocation;; E9 C/ X0 @& Z# ?& p l& R. F
5 v) F# u) F5 Q- import java.util.*;- C Y7 U* i3 J
- & |. ~- l \" ~9 i/ t' H
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(" b: D( e) }, t
! ^3 F/ U) y3 _- c& u) s% G! O5 p- public class LineRender{
; P9 i* I# s* H& ~8 V - private final PoseStack pose;* _" C; V; A$ l8 u
- private final MultiBufferSource source;: g3 a+ Z# N6 {# F. v+ |. ]0 i3 l
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
2 z5 K0 b( u0 h! O0 E - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();2 A% k! x6 d# b& h% v! h) {+ E& q
; R2 T. {$ Q; J# B4 c. P
( C4 z0 @. \' ~2 }+ O* K- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
0 E4 C+ H" F& @+ [8 K2 n - if(x1 == x2 && y1 == y2 && z1 == z2){
$ ^/ h. W8 U5 W, _4 u - return;
- N6 [- h: `3 L2 @7 a - }5 k+ b% q% ^8 P, X- y! a- D
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
# }, }: U4 P6 z' L - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");0 o) j" D8 e6 j8 o {3 f6 K
- }
5 ?/ ]1 ~: L; w - pose.pushPose();
6 R' A: g6 d$ ~* F - final int newLight = convertLight(6);
' B' e* V4 R' A0 W7 M& V - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));- A2 @% ]9 F0 x$ c! e5 B
- final float lineHeightSmall = (y2 - y1);# q/ \5 }: [" y O" a
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);, F: N* w$ Q; D
- pose.popPose();4 W9 q8 `; J& x" r, ~: I3 ^, U
- }
9 u# q: d) h1 R, r
/ a& Y* E6 E! _" u- private RenderType getLayers(String texture, int light) {
9 N* [ X: Z) G3 q" W - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
6 F, O$ [( I, M5 m - }) _/ d# t' H! h5 A2 |1 z7 o) l
" p+ x$ ^( x( q+ i# A2 A" V- private RenderType getLightTexture(ResourceLocation texture) {
5 o1 x) |% z$ R0 E - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
7 w& q" C' H) n2 [ - }
% C" \. E9 @% a8 ]6 A
1 u, f& s$ F, Y7 f% {- private RenderType getTexture(ResourceLocation texture) {% ?8 P. T* |6 d
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
( i& ]* Y% f/ n6 l - }
& g8 M, z B) O& D+ e
4 G# D+ y6 `% Y7 P% a! k' G1 o! M- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
9 v: E" @) P$ I; K: X - if (cache.containsKey(identifier)) {
/ Z% z5 J" b8 v4 p+ d. C - return cache.get(identifier);
' m6 ^9 g& d) v - } else {
/ t$ \) B, ^7 L7 X( ~; o) z6 P - final RenderType renderLayer = supplier.get();
3 P$ x. O# H& s: n/ q& x - cache.put(identifier, renderLayer);
8 c, m# {( k4 l4 V. p4 e- A7 q - return renderLayer;
6 P, u( D8 @ a" A( J* ` - }
$ R5 i& P. n% P2 s - }- u* M7 k; ^6 K% x, m
- }
复制代码 |
|