|
|
( L1 g. Y% W$ F行,这个怎么样) U' r) Z8 c& b
- package com.xhg78999.mtrfac.render;5 D) d2 G1 q. s
- 8 b) A" p6 b% j5 M
- import com.mojang.blaze3d.vertex.PoseStack;
2 S# v2 X( z6 i - import com.mojang.blaze3d.vertex.VertexConsumer;# i3 ^3 ]! g! c6 I% O8 {+ F% Z4 s
- import net.minecraft.client.renderer.RenderType;
' |) B; v- n- m& j0 q9 C! b - import net.minecraft.resources.ResourceLocation; X) d7 i" X2 _$ s* y; m
: E* D. \; ~7 |0 ?" e2 ^" A" X( K- import java.util.*;0 o& [, }3 S4 X
- ; s+ S% i" z! b0 }6 r
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
% y9 S, w5 Y1 i
+ m1 k. b9 L1 r2 K4 J; Y8 U- public class LineRender{" O5 F5 j$ s: }
- private final PoseStack pose;5 T4 C% m# M L3 x- E1 }
- private final MultiBufferSource source;& C: x2 H& @# A- Z1 P. Q, T3 x2 Z
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();4 G* X1 a7 M. f+ L# s: m
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
, R, o4 p! f& o- d' B - + z9 ]* ^' ^( p P! k7 [
- 0 ~+ w6 q- {1 _$ X" E
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
. T+ ]7 o) p; Y4 g - if(x1 == x2 && y1 == y2 && z1 == z2){
, n" w5 [/ b# {& Q; W - return; J c* n5 `' E
- }% M2 L' P( N4 x) G; g+ p7 w
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
+ q3 i( P$ O5 S2 \: j9 U - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");/ E5 G& o7 R2 M# G0 a% w
- }
- h/ v- z: w( b - pose.pushPose();
/ }% x0 Z3 b. p4 x - final int newLight = convertLight(6);5 w* }( r- j' t0 \( \
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
* K: Y" l. F5 o4 h! M2 _$ p - final float lineHeightSmall = (y2 - y1);
9 \$ E+ ^& W U$ [8 K9 B8 U8 q) c - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
# o; A; o: {% l! z - pose.popPose();" F/ x( E4 N0 h
- }
D6 t5 r! y9 |
$ f2 a/ L- m% X' s+ U$ I# ~- private RenderType getLayers(String texture, int light) {# P& y4 L/ O Y8 p0 ]
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));6 m, h3 a6 F$ \7 E
- }$ S' l2 d0 ?- M% [' Y
- ; d7 Y- p, u- U. x# h
- private RenderType getLightTexture(ResourceLocation texture) {0 ^% A+ e7 {3 B1 t
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);0 h: B# J$ `) h: {
- }0 w& j7 K; T9 M) p. E, V
Q5 T3 ^2 S$ _5 Z/ I X. o+ y- private RenderType getTexture(ResourceLocation texture) {5 e: L/ \% w% P" m+ D
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
4 S, o3 J6 K. N/ T - }
( x+ g$ `) a* q: k& R1 d# C
8 B/ m/ W, R$ q2 E' |- o p9 a& m- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {, W( r5 {) S1 |& u
- if (cache.containsKey(identifier)) {
. ?: s+ S3 ]$ ]) S2 \ - return cache.get(identifier);0 n7 `2 t4 c% i
- } else {
' `! |/ ?- L8 n5 a" \ - final RenderType renderLayer = supplier.get();# H: n% Q; ^9 i9 J' _( T; A% q1 i
- cache.put(identifier, renderLayer);
\8 m' b2 ?" R7 ]8 y+ Y - return renderLayer;
1 g9 a1 [, J# K% t: T5 w) K - }
. q1 P0 [' ]: ]2 ~ e - }8 y4 }# C) c4 s% r' ^
- }
复制代码 |
|