|
|
4 |! i, V' j+ v) L3 C v1 W行,这个怎么样
) z, k8 P1 N- m8 ?- package com.xhg78999.mtrfac.render;; c5 \5 O: x4 L2 E- z
- $ R ?' d, |& s( o5 D; }+ W
- import com.mojang.blaze3d.vertex.PoseStack;/ w. t% K9 p. M* b# i# K
- import com.mojang.blaze3d.vertex.VertexConsumer;/ E/ v7 _+ l0 d
- import net.minecraft.client.renderer.RenderType;
& X6 g" q- j4 W - import net.minecraft.resources.ResourceLocation;5 N1 r2 Z& [5 W8 Y$ Q
0 T. K* Y2 `1 z1 D( L- import java.util.*;' E7 t/ s6 i: \( f: V: {
- - Y) y6 S$ c, l
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(* e' ?5 q0 x7 F* A* s2 `$ B
' e& U) x; D! ?0 _* t8 [- public class LineRender{
) Z t4 W& @$ z! l - private final PoseStack pose;
4 c, D) t) |2 b. x - private final MultiBufferSource source;# A, a2 x5 n; Q" w
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();! t0 @% a; A; _9 [9 C
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();2 {" ?) {- j& P3 m
) c; u+ l- u3 }4 x! d- " q8 @- m' R. e% W# T
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
; s$ Z0 H' [3 i( Y# _! {8 u8 i0 s - if(x1 == x2 && y1 == y2 && z1 == z2){9 v' p+ g2 O# p
- return;7 [* d, l/ h' K$ h# I, y' P
- }
- K; G9 ~7 @1 ?* V3 s/ M - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){+ [: R& B. Q' F8 t
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");+ {( ] x4 i- \! n
- }
- N | K6 g5 f. ^* V( _/ u - pose.pushPose();" v1 c6 B8 d2 F' [! F
- final int newLight = convertLight(6);8 H9 x! I- [( V1 j2 l3 \
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
0 |2 @- A' X7 K, n1 \, L - final float lineHeightSmall = (y2 - y1);9 h. f1 V; Y. Q' H' {( T5 P8 Y
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
# S% ^2 h1 T6 L8 h: O( T - pose.popPose();% t2 X& t$ w' K# F4 I
- }
* d4 ]2 p+ T! X1 B - # |, x3 l" ]4 K+ f7 |3 j Y- b
- private RenderType getLayers(String texture, int light) {
. R1 w6 A' @3 t4 {* c& I9 R2 I - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
: W2 Z1 j' V( p, ~6 v7 a - }
6 G% z1 T, V& Y3 ^5 H5 Z
- W) F9 j. ^( [- y8 r% F2 y4 u- private RenderType getLightTexture(ResourceLocation texture) { Z1 E+ P- V2 h4 X' `" x) ^
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);! H5 A/ H v: U8 }
- }: o; k, U4 v* r4 N. v( f/ D
8 x; s& y/ ?7 {6 |' z8 m$ ]- private RenderType getTexture(ResourceLocation texture) {1 j1 w" W) z0 m, N' ?
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);: I( a% V, ?1 a( W9 h4 E
- }$ d, \0 v% i/ i2 J
- 0 \$ _- f( N: m( m7 d. K2 t' z
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {2 {* W5 \* h! P- z7 R$ A0 _
- if (cache.containsKey(identifier)) {
1 Q. L* \/ \6 Y g - return cache.get(identifier);
8 j f$ Q8 A5 O, j% p. r - } else {
) n6 Z. K* h; U% L U K' ? - final RenderType renderLayer = supplier.get();* B8 i5 u8 i" B* [
- cache.put(identifier, renderLayer);" v0 ^- X8 e) n+ _' H/ Z
- return renderLayer;1 L5 y& k( l9 E& \) Q0 m
- }
- P- X8 K+ C; ~6 p2 z% l# C - }
# }& B7 V$ E, _/ A4 G' A1 s5 n - }
复制代码 |
|