|
|
2 b: r- u+ p8 r: T$ ~) X行,这个怎么样1 W# B& G. {1 k( r6 p( I9 d: f# P& R% `
- package com.xhg78999.mtrfac.render;
& [- i9 t/ w: o6 W - ! }7 j6 @. ?! ]/ m. n- f3 u4 l
- import com.mojang.blaze3d.vertex.PoseStack;
( j0 d8 M) @+ m, n6 i4 V4 r - import com.mojang.blaze3d.vertex.VertexConsumer;$ I! I& i! z8 q) N* [' I
- import net.minecraft.client.renderer.RenderType;
9 ?& {7 S1 ]. j# A4 l! [( B$ M# V - import net.minecraft.resources.ResourceLocation;
4 _- @5 y; K2 g9 b3 p7 R - + d5 M$ }3 U# C6 J+ d& E
- import java.util.*;* Z* Q8 y$ R! l) D% c
- " R- a" l9 Z% f: E
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
$ } x2 f& }: D
$ C9 }' t( q* B p" z; Y2 Z5 ^% ]- public class LineRender{1 B/ o1 ^! I: J. }+ _
- private final PoseStack pose;& k! ^' [5 }1 ^( y6 L6 A/ K
- private final MultiBufferSource source;
- |; [, E, E6 r - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
* d6 I0 C( l2 _6 c - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
' B% O# [1 C3 T; O: J% g
7 v# o6 F2 o; H% |* @5 W7 v- . ]4 Z' v* a" {4 W. f
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
% l/ ]8 a( f+ `( i - if(x1 == x2 && y1 == y2 && z1 == z2){9 _$ w: x3 V; J( a
- return;
% f# Y( e; W7 i. u& u - }
" \! u+ ]3 k8 b' m - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
: y" I7 P( x* ?$ q7 O3 m0 F - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");. v! L6 j( v2 [/ _
- }- F E: q2 L' F6 S4 m4 o
- pose.pushPose();
& v( E* ^% x( L. t F8 ^ - final int newLight = convertLight(6);
- ~* C; h% Y3 C9 h% q - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));6 I9 d- J' g4 K+ z
- final float lineHeightSmall = (y2 - y1);: \1 C7 Z! ?6 Z6 q/ X
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
. z/ G7 ~6 Z& W5 N - pose.popPose();7 k, p6 ?4 p" D9 d! M2 ^
- }4 R# z' r6 m4 _$ v
- , S+ n3 w7 s6 {2 M4 o
- private RenderType getLayers(String texture, int light) {
$ y: y3 g& x$ ^ - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
( k+ _$ i% A$ b7 @ - }6 [& j& _/ j4 |7 x$ o1 N
- q/ I- Y( f0 {9 z
- private RenderType getLightTexture(ResourceLocation texture) {
5 C" D" y) C. t; l: L i - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);! {# f; j) `& {) K: R
- }
0 Z( b! D; x: x4 c. k
) A7 {6 k4 w( [5 s- private RenderType getTexture(ResourceLocation texture) {) R& b/ P; c: D% q' |; N
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
/ V" u. _0 Y+ G0 l& `# I - }
- D; |% O* e& r - 4 E5 B# M* E: ?7 p% P8 O& v
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
2 t ]! Y7 w5 k' e2 j5 X! u9 D - if (cache.containsKey(identifier)) {+ i0 F" `4 [% H/ Q( [! u/ ^$ S
- return cache.get(identifier);
3 {+ M. j S) \) P* t% [ - } else {
' A6 q8 [' W9 h6 R5 L9 l - final RenderType renderLayer = supplier.get();8 m9 }# `$ ~ l5 b4 c4 P
- cache.put(identifier, renderLayer);$ Q* R, a: j7 r* N( Z1 \! B
- return renderLayer;
" ^" x2 v, W7 d' a - }
$ X5 Q# R% H- G - }
5 S3 H. U+ ?- K, e: U - }
复制代码 |
|