|
|
5 [% @, B# W) B) M$ ^行,这个怎么样
- i0 r; C; [# j8 R* E- H* X- package com.xhg78999.mtrfac.render;
( V8 d( x. ?6 t# n - - X+ f* H+ u% }( I1 n8 C
- import com.mojang.blaze3d.vertex.PoseStack;4 d* _5 O' x- }
- import com.mojang.blaze3d.vertex.VertexConsumer;! w1 a8 E$ s4 x/ O) w
- import net.minecraft.client.renderer.RenderType;7 {$ U4 G) B; J* Q9 O
- import net.minecraft.resources.ResourceLocation;
, [' V+ p) {3 n/ V4 v - 2 j/ h. f7 Z! _/ f5 F
- import java.util.*;
3 p2 r. o0 g& Y - 3 w; e& S% r% q' N
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(4 F" e! s$ ], B7 I: |, r3 g
- ! n! y; V4 V- N( `% ~8 ]
- public class LineRender{
' D' g2 Y3 o3 u& i - private final PoseStack pose;, h6 m( h2 l5 q( R% q2 p
- private final MultiBufferSource source;- |8 n& l7 }: C& K: \& B+ ?
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();1 P J7 x/ k3 z9 A# F0 n' g1 N2 a
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();. H# w7 R5 o+ t
7 v' j z" B6 ~& p. f! Z* D% f: N- - L. C" }( F* I# g! Y& V
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){8 {* X t, q2 b Y; _9 N: P
- if(x1 == x2 && y1 == y2 && z1 == z2){
) I6 o/ f, I1 F6 \! F - return;
4 Z) `8 ^# r% i |5 f& l; z. k& J. [, W - }* J* I- A9 X6 s% z @6 \8 s6 m
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){ ~! B! P# C$ F; X& w+ h4 f) F
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
0 r# X e# |; X6 y - }
( |9 {9 |7 L/ w* ?+ J6 P - pose.pushPose();
2 c5 N! t. W5 ]9 D. R - final int newLight = convertLight(6);
7 U: M3 [$ R, V/ v# K7 V$ H3 |2 t, U - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
4 @! S8 ~" v+ c E l - final float lineHeightSmall = (y2 - y1);
- V6 `' m% S' i& A. _+ Z, t - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
: S/ o* \/ y( |; z/ v - pose.popPose();
2 q5 m2 N# D! ~5 e3 B5 z% S' ? - }) I" z* t) f( m+ q
- 0 H% p# M+ r2 m% B
- private RenderType getLayers(String texture, int light) {
! p# a( S. X3 X3 g - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
' @( Z* @7 Q1 G0 [: d, C( r% ` - }+ A* ?/ r4 v* M" k& I: M9 Y
- ; D E7 k- x3 [6 ~( C. y6 d
- private RenderType getLightTexture(ResourceLocation texture) {
3 S% s8 l+ ?/ q: f - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
2 ]4 a9 S# \' ?8 b$ k1 H: {; L" h# o$ @1 S - }
4 s, q6 f2 R; a9 k
6 ~5 X! M% p$ [! n, g- private RenderType getTexture(ResourceLocation texture) {3 P# z5 t* z1 n
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);2 ?1 _3 B) u6 T0 E0 M
- }
, Q o4 C* _$ ^, T1 x
9 g# y6 M$ W1 |- b- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
9 d: Z4 k. _" N$ H% C. w - if (cache.containsKey(identifier)) {
# ~, L+ l* I! x1 Y - return cache.get(identifier);
9 Y4 K5 [" s1 s: P6 ^" l e' J - } else {9 k% F+ x4 J: Q0 r3 m- N& y2 w. l
- final RenderType renderLayer = supplier.get();
8 C; D6 W/ k3 h - cache.put(identifier, renderLayer);
) |# f; x7 Y [6 q1 n% i$ K4 B - return renderLayer;
4 G' M: ?- A; y: I# C; V - }
$ z% _% }6 a+ M7 Q5 }* l - }6 p5 V/ {/ H0 P' H
- }
复制代码 |
|