|
|
! a9 m. N9 ~- [9 B9 p行,这个怎么样
\2 i( x) L# v- ?- K- package com.xhg78999.mtrfac.render;. e2 s. R1 \( G& E* ^$ g, j, m
- # T: S- {" |: l2 U! B8 J9 O
- import com.mojang.blaze3d.vertex.PoseStack;
. `5 V. g: |0 F1 h: p1 f - import com.mojang.blaze3d.vertex.VertexConsumer;: x* R5 f/ k- n' `7 q7 A
- import net.minecraft.client.renderer.RenderType;5 b1 t, b) F" y6 t3 ^9 ~: y4 @
- import net.minecraft.resources.ResourceLocation;1 ~# U( q* G2 s$ I: G1 s
- 9 S- r2 x& n4 [0 s H
- import java.util.*;' y- l/ ^% W# {' n; Q$ @8 i8 g; l
~: Y$ S1 o1 j) I/ C- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :($ ?" F4 T1 Y" R$ L5 W
- ( T, [6 l, w" _* F: p& E t. N
- public class LineRender{
8 ] a/ o9 R- }1 ?) {/ U( t) D - private final PoseStack pose;
8 M( J* @, d/ _3 k* b$ f: w8 \" u - private final MultiBufferSource source;
}& j2 [" g9 x; q- p) z - private static final Map<String, RenderType> CACHE_A = new HashMap<>();8 M8 I5 G& w+ |4 J" e
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
% g- K# p2 ^5 e Q3 P! a G7 m, o
; F0 r$ t( {( y8 f5 q+ Q) e W4 ~5 n' ]* ]
9 {4 V& n- E: e3 ]% Q' ~/ m- Q- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
6 y: s. A' y# s2 A q1 l0 X - if(x1 == x2 && y1 == y2 && z1 == z2){
& n; g" o2 P5 ~" s2 }$ z. X2 o: m - return;
; `& N6 p z' e; o7 t. n - }+ \- ?9 V' E0 h, A. t8 G
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){) }0 `4 S6 ^8 v
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");6 H0 H2 \- A! y% O3 _' m* Q
- }
; ~3 r8 n% l; {/ R% R E - pose.pushPose(); I9 O" P4 a# o, i2 N
- final int newLight = convertLight(6);
4 U/ r0 c; ]% O9 ^( } - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));# {! X+ \) j2 k3 J' j v
- final float lineHeightSmall = (y2 - y1);+ `- a- `, G6 m0 ?2 U9 {5 F
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);4 A; D7 O/ B$ a z4 y7 s6 H2 l
- pose.popPose();
6 w# l: `1 O6 j) ~2 t - }- s3 p* ^# W0 w: x' C B- b8 _
* u+ c [( g/ S q- private RenderType getLayers(String texture, int light) {4 \5 G) @9 ]& c$ n% ^0 u
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
" L, p S4 Z* s* r8 { - }
p1 ]1 l6 i! I - . _8 R3 C& _0 D5 _/ ]2 B: c
- private RenderType getLightTexture(ResourceLocation texture) {
1 R) T. m X- s* u4 t% Q" @1 j - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
8 V7 ^' @* L6 ~0 Z6 K' [ - }
: W" W f: M9 P7 ]
, w' P2 N; [) s! Y# o+ m2 {/ ~- private RenderType getTexture(ResourceLocation texture) {
8 ? L) b( @) W, J/ I- }" t - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
" [* P( y6 z3 Z- M' i1 o+ `" a( C - }
; N) d0 |/ [7 V+ g
% c- a5 }' ~& M- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {1 R9 m& b/ k! r7 R) H
- if (cache.containsKey(identifier)) {
. S7 n& I/ O; g9 Y4 D, z0 `! k - return cache.get(identifier);% T2 I; o: p9 ]+ i8 G
- } else {
$ n& h, k( n l - final RenderType renderLayer = supplier.get();7 ]' ]+ p. y. T* I
- cache.put(identifier, renderLayer);
, j. m; p6 v6 O# \6 H8 ?/ J; p+ { - return renderLayer;
- U; C# k% B( T U3 X9 c - }
$ A5 M% `3 B7 R! M4 L$ l+ d7 F) F - }
9 c1 o d+ f! E; x* J% k% k - }
复制代码 |
|