|
|
6 v. y: e8 A5 m% i8 O行,这个怎么样
9 s% |( ]) [" Y- package com.xhg78999.mtrfac.render;/ I$ ^- g$ C8 \9 ~ M
- 6 X. |/ x3 v/ ?5 l' ~5 X/ y# e
- import com.mojang.blaze3d.vertex.PoseStack;
T3 W* `# T' z - import com.mojang.blaze3d.vertex.VertexConsumer;
: H- F1 B6 P r) I+ M* r - import net.minecraft.client.renderer.RenderType;6 \3 l+ \1 e2 \1 \
- import net.minecraft.resources.ResourceLocation;) E4 I. O1 }7 O
$ a) S& [! j. j0 U& M+ \* z- }- import java.util.*;
6 f( n; K t/ I1 C: }9 a
# C% _- P: V8 d- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(2 Y, k' Y, T2 Y3 C3 Z0 R) }: |
- & I% T5 Z% r" z; I7 L
- public class LineRender{
8 ~* K$ c, J% q9 F - private final PoseStack pose;
4 x; x1 i* l1 c8 b( g - private final MultiBufferSource source;
! \! T8 a5 u6 |4 m - private static final Map<String, RenderType> CACHE_A = new HashMap<>();5 @4 @3 ]3 q G5 e; a9 c
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
9 z7 R6 D& F5 s$ s9 I2 Y v
( b# W9 W) l3 M' f; ?- |; x
3 S6 q% K" l) D4 s; o0 F" q' ]- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
) ?' f- C( A5 f% j0 J8 E- @ - if(x1 == x2 && y1 == y2 && z1 == z2){
3 s( O& i/ y/ i6 Q - return;0 B" Y( p1 I, E$ G1 ^
- }
& b$ Z2 C2 D' _8 d/ u - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){! {( x- }/ L% g+ ]6 E5 _6 z
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");: k j, e& B5 ^7 b/ r) x0 [5 u
- }6 y# t! V$ i& @2 @/ [+ C3 f% ?
- pose.pushPose();
8 R* a; a9 |# \( g; P! q. f - final int newLight = convertLight(6);$ P% x E( D0 R% h- b
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));, q! I' y( }0 X, G" x0 R
- final float lineHeightSmall = (y2 - y1);
/ R3 a* o' n- E2 Z# ? - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
|% r0 ~) m; U% i - pose.popPose();
$ L5 [3 f8 m' o$ l+ I% | - }, N' R+ W/ B U4 z0 a5 C- J! O
& v( Q" A0 E2 O, q+ ~6 Z( L- private RenderType getLayers(String texture, int light) {7 l2 G3 m( v+ S& q5 f1 {. P8 `
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
7 j3 {7 J- U: @( ? - }
8 j! U' a5 j8 u& m1 X7 S& s2 |
% _& R) O# G" S; C1 J- private RenderType getLightTexture(ResourceLocation texture) {. Y$ I6 ^9 |+ k- J
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
0 s: _' w/ P% W2 J! T - }) }3 B5 z' A9 x
- : z ?, f+ F" I5 h( A
- private RenderType getTexture(ResourceLocation texture) {
0 d( O2 T1 K8 V4 J2 T1 C - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
: L" l- f+ v8 a5 j - }
: g- c6 F1 j4 |# T4 t3 k - ) e0 f: r4 ^+ m( j6 _. |
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {' z: Z4 G q5 e# Q- i' i. @/ s# h* \' h
- if (cache.containsKey(identifier)) {
% c& K2 a. W- s" B7 d ` - return cache.get(identifier);
' g: ~8 p& E" P4 H5 C! J9 r0 S/ d- E - } else {, E2 y- J/ ~+ u) i& l7 ^ r2 w% c
- final RenderType renderLayer = supplier.get();
% \- r# v2 p+ u' A9 O4 u - cache.put(identifier, renderLayer);$ W0 P0 p1 ^- ?- C6 E
- return renderLayer;) S+ J; m9 B: e; h
- }* F+ z1 X% c3 V5 b% ?& ~
- }- e2 Y0 F% N, s" J+ P: {' o; M
- }
复制代码 |
|