|
|
0 ]: L {- D# u) }5 J
行,这个怎么样2 D# e! c8 m* q8 e+ a6 D
- package com.xhg78999.mtrfac.render;
4 L0 Y1 Y8 z k
I h7 e0 S( {8 k, z% S4 k2 M5 \- import com.mojang.blaze3d.vertex.PoseStack;) U2 P4 B, u! D4 K. w. J8 a+ H
- import com.mojang.blaze3d.vertex.VertexConsumer;( @: S+ F2 h1 w: z- ^* j
- import net.minecraft.client.renderer.RenderType;- y. X! @0 k. @1 N4 c
- import net.minecraft.resources.ResourceLocation;
/ u& F$ ~# v5 m/ v. o0 z - 7 v+ J, g9 k& P, }3 p6 O7 D
- import java.util.*;
: _. W. D& M7 \- f* F5 s
3 _; J7 w8 g r. }* p6 `! f- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(6 N! [ @; {" Q; ^$ h: m
! |5 X+ Q ?% d3 U- public class LineRender{
! t, C" ?" `1 x* x - private final PoseStack pose;" Z9 X. j( ]6 _ I3 v& R
- private final MultiBufferSource source;
' D; `0 u9 h( z' V3 ^3 Q4 @% B - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
! ?# E7 [, |+ h) Y; z R L - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
* a/ g/ ]% K! k" U
! ?! |' I* @* l/ ?+ K+ x- / p/ H2 w' S1 r
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
, W( K/ Z) J; C: O" X - if(x1 == x2 && y1 == y2 && z1 == z2){
+ m4 z& Q2 W8 @% n6 X4 R! j - return;1 D# M9 L6 u8 v; ~4 H* V! }# B, |
- }
! I5 V, e) j, N- K; A8 R - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
/ f) R( q; E) @$ Z% s5 v: } - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
1 g$ J/ a3 g. O" \3 K - }$ _( U1 x* o* f" P- R; Q
- pose.pushPose();
* u8 h# J0 c+ J B" j - final int newLight = convertLight(6);
6 o- v- L6 R9 R) k& ?4 Y - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));- p0 h7 z; B7 i+ \, ?+ `
- final float lineHeightSmall = (y2 - y1);( \" Y0 V, M! P5 V' W
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);1 i J+ Y1 k" P6 J- J
- pose.popPose();0 o5 m0 V, j' C& w- a2 N: k
- } U. E0 N3 b( R. C+ u0 Q) T1 O
- % Q) K; U) S" {$ z
- private RenderType getLayers(String texture, int light) {& _* q$ l' S* k- e; i
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
! D. U+ s8 v" D) }- m2 u - }
2 R9 \% |* C) i% o# C - # s7 k. R" W7 w8 F, ?
- private RenderType getLightTexture(ResourceLocation texture) {7 A% w3 X z; L8 j6 [0 H! n
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);2 w2 ~: i* d- c: w) }
- }! k2 R. y* L' B6 _- R% _
/ P2 Z; ], S7 r5 ]+ W- x# k. G5 X0 l6 |! M- private RenderType getTexture(ResourceLocation texture) {9 Y7 @6 ?0 H% |3 e- G D, k6 Q
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
5 K! k" O$ F+ f - }7 v5 ^1 e' L. v$ {# K; w
! [' l9 y' z/ e5 `( d, E- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
) m+ I! d" j2 j+ ~! H - if (cache.containsKey(identifier)) {; O% O0 ^1 t0 M0 H3 ^
- return cache.get(identifier);
4 |6 R( @: z: T% | - } else {, y/ e1 m* g, Q; h6 j3 Q9 C
- final RenderType renderLayer = supplier.get();4 T" j4 ^# B* d& ?( X. z5 |# o
- cache.put(identifier, renderLayer);
- d2 p- }/ L1 k - return renderLayer;" J: q6 a) ~& z3 @
- }8 E0 B5 E m. j; O
- }
+ G; s& {& g/ \7 X1 Z/ `' t - }
复制代码 |
|