|
|
4 P& I# {4 o' E% M- O0 ]
行,这个怎么样; |+ J6 K3 a) d1 |; p
- package com.xhg78999.mtrfac.render;8 K' _: Y4 R+ X2 J
- , \* Q2 t1 F z& i& x
- import com.mojang.blaze3d.vertex.PoseStack;
& F$ V, {+ _6 w7 Y) H. x - import com.mojang.blaze3d.vertex.VertexConsumer;
2 x) e) x( N9 z% {( v - import net.minecraft.client.renderer.RenderType;
) E H! R# D/ ^! T) z' P" l - import net.minecraft.resources.ResourceLocation;
- M: E g4 S3 l8 }4 F* w6 F - $ U5 d! N3 T% f/ \8 q& C7 s
- import java.util.*;% {- _: n2 X3 Y. I" H
Y# a* b R( [! A7 W; q7 n- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
' c3 f* S/ D# q |, [2 q - . p/ Y, D, A' Z; j
- public class LineRender{3 j$ [. o; S" w' C: p0 \5 K
- private final PoseStack pose;% c6 F' n, j6 M. L# C
- private final MultiBufferSource source;
% Y9 r2 \3 F: B8 S; }: v: j% h8 d - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
9 j( C3 l3 l4 e+ h2 S5 ~' ` - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
( G7 R" K% `! Y) f* l - 1 a. S, R5 Q c, z' S, n& H9 j
& K" z" N4 j1 ~2 {& g" d4 J- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
$ W+ [6 D5 \6 N% Z* x& R6 z6 q - if(x1 == x2 && y1 == y2 && z1 == z2){6 e) x( c: a8 o3 T
- return;
8 }+ S! @/ \; \ - }) m. K5 f0 d" R
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){4 w4 U) }2 u$ H
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");% a0 n9 U$ I! i# k7 s
- }: B9 B, B* @1 i* N8 a# e
- pose.pushPose();
4 _- E& B6 ^% G; P - final int newLight = convertLight(6);' k& V2 m+ V4 I% G2 O- c
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
# F1 M5 j0 D: l% T0 M - final float lineHeightSmall = (y2 - y1);; B# l- f! S2 R6 n9 z
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);+ [0 u" l# _9 t3 J3 S' `, g
- pose.popPose();
3 p% b. L. Z% h- e# m! g - }! s# c# v! J( p3 _
- - S6 z) l$ H+ M& U6 j
- private RenderType getLayers(String texture, int light) {
' T6 u4 C; x1 n$ R! X( {0 R - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
: h, h4 c {& H - }
1 @6 I; \' P+ c- y - & t5 y; e4 t+ J0 \
- private RenderType getLightTexture(ResourceLocation texture) {0 W, v* F- w% B0 g
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
L1 o, h9 q* q+ @6 T4 u/ V - }
! k& s# A/ t0 x9 N- U5 I - , ] }# r; O9 H7 {' H+ A
- private RenderType getTexture(ResourceLocation texture) {& d" n) \ e$ f4 p2 M9 W I2 r
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);, i8 ~9 W6 U8 J9 |" ?# A
- }' P# V8 H7 [7 z* C9 u( i
8 C8 J3 v5 Z# b( ]% Z; x8 E) z- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {! t# J+ Y% f, m+ ?9 Y( B0 T
- if (cache.containsKey(identifier)) {& u4 b3 A; z) d1 z& x* o- j& R
- return cache.get(identifier);
# f& H# C/ t. W$ c2 b( b - } else {
+ I' |; f4 S8 I$ r, U - final RenderType renderLayer = supplier.get();2 c6 O* F0 m' o! x# a, u
- cache.put(identifier, renderLayer);
: I# h, d4 s# N# G1 W8 H& R. L - return renderLayer;2 j+ p; y) f" T- d0 Y
- }
$ o. e l+ b4 M: G' `2 N' l/ ]- ^ - }
- x0 K, K9 l+ `3 L/ X1 t - }
复制代码 |
|