|
|
# U6 K i. e3 M5 d5 t% R
行,这个怎么样
) z) J2 T. }% `- package com.xhg78999.mtrfac.render;8 B; _" P( c5 W9 z% R7 X# F
$ t0 W! p4 M3 v8 E9 \, [- import com.mojang.blaze3d.vertex.PoseStack;
& f7 y9 l9 P) M( d. U L, u0 B# D - import com.mojang.blaze3d.vertex.VertexConsumer;
3 P0 k( v- I$ E S - import net.minecraft.client.renderer.RenderType;( S, { V* [# s( ?% Y2 g, t
- import net.minecraft.resources.ResourceLocation;
. l1 a! R0 D* W5 Z3 a - 1 ^ ~8 X# `+ D5 ?, d
- import java.util.*;
% M: l/ J S" k1 K! j- p
( C( ?' w( c, Z( X2 F- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
9 @8 W8 O3 Q) J2 m - , x( Y! }1 |) g& \, `9 L# ~
- public class LineRender{9 l0 o* M( V v! U% S6 x( ^
- private final PoseStack pose;
7 r' P% ]% }. j- c7 M& P! e. b - private final MultiBufferSource source;1 z5 k. }) V. v8 d& G# K
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
: @! J# a( g7 m( A Y - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
" x p+ T' n7 i2 d
4 n8 n" ?# J( a- l4 z0 p: P( g2 x: r# w$ D9 y
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){% B1 D. u( F6 \4 |& h+ _; ~
- if(x1 == x2 && y1 == y2 && z1 == z2){# I2 t5 n8 Z' U: w
- return;; r+ A! n( m. B" K! g& \
- }
- X9 w$ b' Y' t" X2 q - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){5 k- t7 s2 I$ L1 P: z
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
* U# T" B! E$ l& o - }) Y K, ]4 c; }' c6 t |+ v* X
- pose.pushPose();8 {1 T% J- E7 O
- final int newLight = convertLight(6);. {7 ^4 i- s" x6 ?" [8 c6 s% G4 G2 o% _
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));" l+ ~/ p' s3 R. f/ O
- final float lineHeightSmall = (y2 - y1);( K" }) K9 l9 {# c1 X
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
) \$ Z: P1 \: }3 Q s - pose.popPose();
0 e' g$ j$ r: P9 V7 r# T - }
& V z5 l. h0 ]/ i1 K* S - ) `! t6 L% \' M; K0 ]0 o2 @
- private RenderType getLayers(String texture, int light) {
/ o$ K* g* q9 m* o; u - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));$ P7 @* w8 d4 d
- }
/ I: v& m! O1 q, N2 S/ j* D, _! W - 3 A$ i! h! A: b0 _4 L
- private RenderType getLightTexture(ResourceLocation texture) {: _. X4 W; A7 b; U( H
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);3 f1 O4 Z' ^% U" j
- }- e5 E) w, N+ R+ d
/ ^9 w8 P2 _. P6 ~! [8 \+ o- private RenderType getTexture(ResourceLocation texture) {: q! e; Y* C8 X; m
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);$ E) {; _! E( a
- }
8 ]) I4 F5 \. S
% V1 y) d$ a$ O& k( T1 U9 w& V- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {9 X* y) B# r5 O8 w+ {- v! V
- if (cache.containsKey(identifier)) {4 j, Z$ N7 Q( ~" a2 M! t$ j3 M
- return cache.get(identifier);0 O& L+ u9 E" q4 D
- } else {
% {- M" }3 K% Q" T6 b( ~ - final RenderType renderLayer = supplier.get();
" `% U3 D9 t+ ^5 k6 b, V - cache.put(identifier, renderLayer);
$ x3 @9 v- q1 }/ R - return renderLayer;' t0 {9 O; W I
- }
1 U1 y C3 z+ Q% Q T - }
8 ?0 M$ {7 r- S& @. F. K- a$ i5 ~ - }
复制代码 |
|