|
|
: i6 M% m# e G% [7 W X
行,这个怎么样
7 N7 i2 Z0 P) ^) j- package com.xhg78999.mtrfac.render;
# D$ c; V( `- J( R - 9 S0 c. h- k- h" [8 P
- import com.mojang.blaze3d.vertex.PoseStack;
; M, i5 O7 g+ M9 l& n - import com.mojang.blaze3d.vertex.VertexConsumer;) K+ [* n7 @! m# n4 \% L* W. M
- import net.minecraft.client.renderer.RenderType;7 d2 |' v+ O% e8 y1 m: m! ^
- import net.minecraft.resources.ResourceLocation;
5 E7 H, J9 S1 u% ^( X7 J
8 ~6 S/ z4 O4 A- T) z- import java.util.*;
* n- S( T! k* F( \6 _& x - # t; t* Z& P- C3 [
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
5 p, o- d9 ]( L- ]" \" q+ S+ z/ n - # M# ~6 i b4 x( p
- public class LineRender{
% T: l& ^; t0 [9 Y: l) A) A - private final PoseStack pose;
: _% v2 ` m+ j5 L% M2 U - private final MultiBufferSource source;: ~8 R; }0 S1 ^4 @
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();' b+ v: X. o" w7 e& l& N% m. ] u0 G: K
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
4 D; L O3 p0 x2 E - 2 ^' ~; q% V( H7 Z# `
* E# D3 L: q, H: n" |- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
! t0 @/ w" h& ^7 {* D. m - if(x1 == x2 && y1 == y2 && z1 == z2){7 G# f; w* x% @' ]
- return;$ Y3 e! E- n- u3 k4 z
- }
. `/ Y" A( u! |- G/ B& \ - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
$ M5 j5 n: O5 E8 j - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)"); C- }) f5 |/ s/ L# F2 c# p
- }
2 l4 k7 b' x! q! Z, T. A - pose.pushPose();0 v5 N& S, \8 j; Q# t
- final int newLight = convertLight(6);) a3 Z4 z: t- K0 m( s' Z
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
9 m. a# G# I1 _$ g9 z - final float lineHeightSmall = (y2 - y1);, l9 d- b9 j2 `3 K8 G$ ?
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
* w8 f, T0 ~; o/ o - pose.popPose();, ]) A( L8 N* `0 w
- }: E" }4 n' d! A
- ! X0 G# X- s$ A' E: Y
- private RenderType getLayers(String texture, int light) {
, U0 |. g0 N8 q% I$ r1 g - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
( y6 I5 s8 E$ f$ g" w - }" B, O, V: V5 W5 a d
- g- M f4 k; l# X- V( M# j% V- private RenderType getLightTexture(ResourceLocation texture) {3 _2 W4 W3 q# j& Y! z
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
/ J! N# ^0 {8 K1 H, z2 t; O - }: E0 v; q! e0 j- l- e
: N4 x4 U) y3 ?- private RenderType getTexture(ResourceLocation texture) {
6 l! V) @/ c; | - return this.cache(texture, () -> entityCutout(texture), CACHE_B);, j4 {! p, D9 B! M' s$ `8 ?' H ?+ @
- }
6 X* g- u& |; f - / L$ V0 l. ^% c' ]8 a
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
8 X3 J5 L, c: X; x" ? - if (cache.containsKey(identifier)) {8 }- W `* M6 K" H9 E. z& P) o1 J
- return cache.get(identifier);, C3 s6 w+ v$ b1 M, ^
- } else {4 G' r; @8 ]4 o) j2 j8 n4 F
- final RenderType renderLayer = supplier.get();
& ~0 o/ V% ~1 H1 W6 H$ s5 F: v. j - cache.put(identifier, renderLayer);
% [, {5 S( b3 ^ - return renderLayer;+ _6 }( ~+ v' q+ { N
- }& [. x% S8 e4 ?* G! S( w! L3 U, J
- }/ P. a% U% k7 N" C
- }
复制代码 |
|