|
|
8 I8 H. G& p7 @5 V! @
行,这个怎么样
4 x7 B; y8 t0 Q% R- Z9 l- package com.xhg78999.mtrfac.render;
' B( M2 `/ H. c - ! W2 Q* O- j0 |; K9 X
- import com.mojang.blaze3d.vertex.PoseStack;
# j) R0 d2 F) z5 U( b+ R - import com.mojang.blaze3d.vertex.VertexConsumer;
- O/ t) ^) r: z6 u8 D7 t+ c - import net.minecraft.client.renderer.RenderType; G9 C: U$ {# R3 _
- import net.minecraft.resources.ResourceLocation;
7 D* P0 h# Q/ v; q - 2 o5 r, {& u @0 h
- import java.util.*;
/ \, s, U- T. \2 y
2 [) l V f/ l% i- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
* N/ V U1 c b3 c9 ^4 b2 l
1 Z6 A# L* d# T2 X! f- public class LineRender{5 {: r$ ]4 V9 z }/ p1 \* q
- private final PoseStack pose;
1 C5 O8 G& o, s: |7 a+ j7 ?5 M - private final MultiBufferSource source;# M3 P. K5 v1 L, f- k
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
! O7 m6 [5 r8 y: H% ]% y5 C - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();# u) P) J/ C0 |0 j
3 Z# Y5 V9 S3 K- 4 G. O$ a1 H" F, g6 L. W
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
+ t7 `2 b$ x! P. Y0 [ - if(x1 == x2 && y1 == y2 && z1 == z2){( _8 [% N0 s9 F" I) @$ ~& B
- return;& ]1 c" E* |/ ~, U
- }
: e8 V" u0 `$ S1 T9 ?) p( |) B - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){1 p; }8 w% d% d. e: x& B/ t
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");% q0 e9 g8 _9 n# Q( H
- }
9 p5 }/ _ y. j/ H: W& t - pose.pushPose();3 X9 h% y. O, V4 ]
- final int newLight = convertLight(6);
. ~( B. A b1 s# f7 ^ - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
* s5 q" O/ F- u: E - final float lineHeightSmall = (y2 - y1);
% d- D5 U z3 W0 \ - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);0 _* H `/ s. g
- pose.popPose();0 \4 @, b/ T+ W( q* S
- }2 O6 n5 p8 j5 F0 P- L9 G
- ' c; F0 H8 V0 l! }6 y0 d6 r
- private RenderType getLayers(String texture, int light) {: ` b6 D& M1 y! G1 i
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));- N0 s4 }5 z# f) q: x" a& a
- }6 I0 S) x& \# @0 Z* x4 {
' M5 w; A$ @- ~4 A- private RenderType getLightTexture(ResourceLocation texture) {
) U. |% p8 p, r3 k0 J! _5 @- s/ w - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
( y9 Y4 w8 F# G - }
) N }1 J3 z/ m) ]/ n4 b2 [
! g6 m/ `9 O9 F& x; ~* O- private RenderType getTexture(ResourceLocation texture) {
6 D% y( G6 w3 d/ E - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
6 t8 X) Z% P) @$ C: l - }
, T0 h3 k O# R9 {- n
6 e& f- R% G3 i- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
z! v! [. u. {2 ?# l - if (cache.containsKey(identifier)) {% ?+ c3 O7 n S- [3 w$ d8 l+ T
- return cache.get(identifier);
; T, Y' E, L, r4 p2 _/ ~- v - } else {. D% U$ G- b8 g3 i' l9 W/ N# q% _% m
- final RenderType renderLayer = supplier.get();- E" O2 |& o( y" S
- cache.put(identifier, renderLayer);
. }: [# y; ]# Z0 I - return renderLayer;
0 s0 A, X5 Y' o+ ^* q# v - }. Y& a. D2 v& m& ?% u Y& @& ~
- }3 A7 b+ N. [3 h6 y
- }
复制代码 |
|