|
|
c5 E/ B7 t m- l% o, N7 w ?
行,这个怎么样* B W4 H- B. G8 b" r+ J8 R! d
- package com.xhg78999.mtrfac.render;
' N% T( n7 |5 L4 A) l, ~ - ) X1 C% A$ _6 n7 u
- import com.mojang.blaze3d.vertex.PoseStack;" k O9 ^2 k; }: U8 g3 d
- import com.mojang.blaze3d.vertex.VertexConsumer;3 A' C* i+ \, g: U$ ]
- import net.minecraft.client.renderer.RenderType; U( ~4 `& B" D0 L: j
- import net.minecraft.resources.ResourceLocation;
6 v7 t1 s8 F5 B- B4 M; Y/ A - 9 p# S8 U( d) D1 k* ]* h; z+ B
- import java.util.*;
3 `" \/ t4 H$ [$ |9 A% I0 b - / q0 _3 ~7 L( H/ W x
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(7 w; @1 \2 ^, c
6 ~5 f1 R8 K& t8 A {1 R- public class LineRender{2 P; Q: A$ Y' T$ @6 o
- private final PoseStack pose;
1 i0 s1 @9 B* n! ~4 Z! c - private final MultiBufferSource source;$ |4 y: R; B2 l% ~6 s: r* S% |
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();" ?8 u& r) W( o G3 q* j( R
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
5 u; E- z4 \/ e6 P$ A1 l - 7 y9 n0 u* {- R& m1 V$ u5 p
3 C4 | p- p1 s5 q- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){7 R" y! d5 w3 Y) L2 j) b
- if(x1 == x2 && y1 == y2 && z1 == z2){
% K" H' d v! ?/ O( x - return;
' y( Y4 ]/ g5 m: s - }
, d; [; z }2 q2 D% q1 U z+ g+ C - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){. q( z( L6 x0 }3 m
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
# ]) s, R/ r! H: d$ @1 ]9 v, ]# x - }
/ X6 T8 o0 I4 p9 n7 g - pose.pushPose();
8 v1 f2 N8 p7 N5 t# D - final int newLight = convertLight(6); d4 b$ X/ ~5 s! |- a7 }- y. ?/ @
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));; x6 k/ E5 v1 u7 d; c
- final float lineHeightSmall = (y2 - y1);
+ h0 `, b$ p2 O - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
0 T" H! n# H: B1 O+ ` - pose.popPose();
6 z' u- f$ ], q p6 d - }
4 _, n6 b) {% R! t: }" b6 b
1 g/ D; g8 O3 k! `! \+ a$ m- private RenderType getLayers(String texture, int light) {
' K3 K3 p! E3 a2 L9 b - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));7 C8 s' X. s/ Z j
- }
# U' a K: k& v# E; G: w4 ]% X4 ~
8 ~+ Z# c9 ?, J% [- private RenderType getLightTexture(ResourceLocation texture) {5 g% T7 M( z6 y( i6 e }' z+ d! w
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);" w( b* z) c) p" s! S: D
- }
) z" q2 X4 e* U8 H/ ? - ) p% u1 e& q, F: J" d. \) U, c
- private RenderType getTexture(ResourceLocation texture) {
$ R; q; d. {& M* }4 B+ L9 { - return this.cache(texture, () -> entityCutout(texture), CACHE_B);% F. }! T4 M! l& J* N
- }
% G7 }6 u$ f9 |- M8 i/ ?- w - , i. t/ y# z" }# V' |
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
" I; B+ o( e; ]$ m! a! `0 _ - if (cache.containsKey(identifier)) {% v6 I# Q, n4 Z& b. F1 ~
- return cache.get(identifier);
3 v- ]* z! [( C' j# T - } else {
0 J2 e r+ p4 [6 a7 F6 H - final RenderType renderLayer = supplier.get();4 ] O7 r: u; l) y2 @" j% K
- cache.put(identifier, renderLayer);2 N3 [. G5 M. q3 R% K/ [0 a
- return renderLayer;" e9 S3 W; G# A
- }
, f. g" R6 S7 n" Y - }
: O. @- P% J S/ m - }
复制代码 |
|