|
|
' B5 N: X# L/ s/ s
行,这个怎么样
# ?+ u- T7 R* {! K1 e, @- package com.xhg78999.mtrfac.render;. v0 {: R6 ]4 S0 o
- 6 J, x$ ~# g+ |7 i) c2 _' t- [
- import com.mojang.blaze3d.vertex.PoseStack;; ?7 @1 d& E( n6 ^2 i: v1 d( q
- import com.mojang.blaze3d.vertex.VertexConsumer;
- _% o& ^1 l$ u" c - import net.minecraft.client.renderer.RenderType;
( `- {( T: P) {$ | - import net.minecraft.resources.ResourceLocation;
$ W- B# O: U( | I1 @
! q2 H0 r# f2 b% r# a4 \ H* T* C- import java.util.*;! _! J( S$ {0 ?+ f: N4 W7 e
- * ?+ Q$ t2 g. l1 l8 ~5 {
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(8 Z. \# L; E. B: R3 j, v; p$ [' k
- 3 I! n& u" M2 d; ?. r# t$ I
- public class LineRender{$ }/ R9 Q- }. A' o8 H
- private final PoseStack pose;8 W+ p" e9 y7 ~7 Y
- private final MultiBufferSource source;
& ]7 D, @, m s- O0 m% y6 M2 o - private static final Map<String, RenderType> CACHE_A = new HashMap<>();( \1 O. Q/ y y" h3 z3 n. W' u q, C
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();# d* R2 [5 R9 ?+ i, a
6 ?/ C$ [) B6 L! m/ m8 w% e* K- # p1 t0 n4 @$ H1 ]5 h( F- p
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){( }+ @- I4 c7 j. y# P; A
- if(x1 == x2 && y1 == y2 && z1 == z2){
6 C/ ]% T9 Q0 g0 F- p1 k# M - return;
! ^( o3 [& U4 ^" F& G - }1 s3 V6 l2 s1 @- c/ I
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){3 r f8 I6 K. ^2 @1 i% w& v9 w
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");& S* _# @* K- |, y
- }
4 ]" b( `% T: ^6 @% \ - pose.pushPose();* E' H" C9 k9 ?+ ]
- final int newLight = convertLight(6);' s; o2 C0 t4 [/ [3 m
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
- l3 q5 {/ l0 N( p+ Q" V - final float lineHeightSmall = (y2 - y1);6 g# {7 s. P# C9 h/ ?. y% _/ `
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
& }7 A3 c) m, o0 \1 U - pose.popPose();8 T% L, l% Y k- J
- }
7 J/ J) k% s9 J2 p8 e( ?% ?8 M
: z* L( ]& \6 ~. T$ r/ w& i* p- private RenderType getLayers(String texture, int light) {
" \0 o9 D* w/ h* v7 w% e - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));8 W$ V# v- O3 K9 y/ f4 H
- }
A3 E I& g$ `7 b - ! h, v/ w) ^4 ~6 p# m8 m
- private RenderType getLightTexture(ResourceLocation texture) {" m; }! Y v) y; E
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);4 `1 z+ h* Q! b
- }5 P$ u( j6 b$ O5 q A$ `
2 ]1 W+ }; a: Z0 ?# a o/ C# @# l! A- private RenderType getTexture(ResourceLocation texture) {
/ q' n8 Q) d$ Z# ^ - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
# |' C8 ~) @% D4 e3 C4 v0 }9 X - }7 `* K7 S# r; F" H: j, x
8 P O8 ]9 _& M+ h, `- r2 W8 g- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {/ w# H- R0 K5 v4 x7 M: h
- if (cache.containsKey(identifier)) {4 a! c' g% F+ ]4 y. f+ f
- return cache.get(identifier);
+ T8 C7 E# I( L& o, K: S - } else {
% F }' B4 P. n% G; V - final RenderType renderLayer = supplier.get();; Y1 y; S; `9 e2 F) e8 C2 Z
- cache.put(identifier, renderLayer);( S0 A6 ^5 x% k
- return renderLayer;
3 u$ m1 x4 K, ~9 U: c8 G - }. d9 l7 b5 j. O
- }2 U& ?7 P# F" l9 t0 o* ]; c
- }
复制代码 |
|