|
|
" `% P& }2 i! g9 r
行,这个怎么样
( E u v7 G2 ]! y9 s- package com.xhg78999.mtrfac.render;: R( H' E" `2 f) V# s
- 7 Z8 x2 y+ C' B A# I+ ^( b
- import com.mojang.blaze3d.vertex.PoseStack;
" _6 @% I4 T0 S6 t! ]: b' o - import com.mojang.blaze3d.vertex.VertexConsumer;
& V# U* g, _2 [% x+ D - import net.minecraft.client.renderer.RenderType;
G3 Y, r# s5 j$ H - import net.minecraft.resources.ResourceLocation;$ Y$ P8 J9 X8 ~' ~2 B
- 8 y; d8 l5 ]2 t2 n- e! |( C- I- ~- i
- import java.util.*;# p% ~+ b( M h: k* G
- , ]# S; I1 P9 R% k
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
5 l3 C3 V e" c - 8 |. B; ^1 W8 @. w
- public class LineRender{
0 q; r* E9 D6 d5 C - private final PoseStack pose;0 g7 L9 F- W7 ? X
- private final MultiBufferSource source;
- Y; H. s* k2 b; H8 Z( m# U - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
H# C- E! a8 c: _1 Y) I9 _- P - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
4 [9 i, ^) k N' O- e - 0 p# [6 u: e: D( ~% ~
- " G8 F/ X3 R/ }# R, V
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
0 V5 X' O7 ?) ]+ t9 P" p - if(x1 == x2 && y1 == y2 && z1 == z2){3 }- n; Q2 V% K) ]! v# _& p
- return;% M) _" X1 D2 U* C7 w! K4 F
- }
! i3 X7 a1 A1 ~. @; U - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){# H# E: [9 N' v+ p) Q/ o9 E n: C
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");1 j/ e; }& H& C4 y: z
- }
7 N" p" J/ V+ Q6 y3 }% [+ ] - pose.pushPose();! N" b1 g! P$ L. T* b G) O
- final int newLight = convertLight(6);/ J& R" i9 R+ L0 C) r. w
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
! |# i9 H5 p! T z - final float lineHeightSmall = (y2 - y1);( W# @8 Z4 ~0 ]/ s* D; U8 `
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
* Y- T" Z* L6 W, _ - pose.popPose();4 S% h) S* u: H
- }3 b0 Q9 T8 P3 |: z; m
- # C+ {! R G, b1 |5 R: P" b2 C
- private RenderType getLayers(String texture, int light) {
2 P+ j. r6 Z: Q6 B" X& q5 e - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
& |5 y* H, z" w/ U8 o o8 f* P$ ] - }+ i- K0 p3 h: p$ x* f
- , o! i2 ^4 ]) i3 q) h) n' l
- private RenderType getLightTexture(ResourceLocation texture) {
" ^# X' o8 k/ v9 f: U( ^ - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
* g2 T+ `6 m. \) M, K - }! z; [9 `3 t% L9 @
- ' |3 d7 E0 Y/ K! n
- private RenderType getTexture(ResourceLocation texture) {8 S6 j# U- S) @5 B5 x5 n" [: C
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);- @7 m. I/ C- b. @" n ?9 t
- }, g/ U3 g5 r. G1 T# W9 _: w
- 3 s) j7 L4 _! k! S
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) { j5 i& S; w) w2 \' ^9 S; N
- if (cache.containsKey(identifier)) {
' g [9 m2 ^: a. j - return cache.get(identifier);
9 g; W4 G; R1 N, o: e - } else {
& f2 Z; a, C! _2 Z$ X4 f, i - final RenderType renderLayer = supplier.get();
' l5 t! \. ?$ V; y& o" \ - cache.put(identifier, renderLayer);! H5 w. J$ a! ?' Z; a* `
- return renderLayer;* p- ?% S8 t) |
- }$ ]% ~7 I6 d: a2 x
- }
" g6 z5 F# e# @4 `+ u8 L - }
复制代码 |
|