|
|
0 y& y; }& B! m
行,这个怎么样
. i" P8 k4 d& d' C( [- package com.xhg78999.mtrfac.render;6 d% Z1 V* \* K8 N6 G
- % E$ l* ^- X" E6 h F
- import com.mojang.blaze3d.vertex.PoseStack;
8 S) I8 z; G) G' x1 B. R+ | - import com.mojang.blaze3d.vertex.VertexConsumer;7 n# y& A% I4 N. D
- import net.minecraft.client.renderer.RenderType;
3 \! Y6 W! X# y7 J; g7 `0 F - import net.minecraft.resources.ResourceLocation;1 k q1 n* I) l: S4 ?( @8 G: b
- ], I$ R, i, v1 [" I, @, Z1 E- import java.util.*;& ]1 H* e, W! n- Q, z
- 0 c7 d" y/ k0 s4 J X
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(' |/ g3 J: Q5 j* W
: k8 u* g/ Q2 r) ~- public class LineRender{9 J- m& U- F H" O' `
- private final PoseStack pose;
0 F; l0 T) n: `, z - private final MultiBufferSource source;
/ S+ k7 q- X' t6 I) l' c - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
: a. R3 e) k8 q. t - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();/ e% H" A9 [9 I- Q7 z. m0 [
) G* \0 f& s5 S2 Z. T/ B2 T- J
: _+ {5 ]7 p2 h* l! E- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
! J7 }& n8 s# w6 j0 W. B1 e - if(x1 == x2 && y1 == y2 && z1 == z2){. P8 u# l0 N+ F8 [1 t
- return;
6 ~- [. E% J- h8 [ - }* J1 i! S' J( E e1 {: y# R
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){% c g3 W$ o8 g+ ?1 n5 M
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");/ f9 E) n/ ^' V
- }4 a) A9 c' m, d
- pose.pushPose();# T; v$ S7 }8 {( z+ \+ R2 c
- final int newLight = convertLight(6);
0 L# Y# `' M v V f4 u - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));1 C; y7 {% P, }
- final float lineHeightSmall = (y2 - y1);% R( s0 N8 a8 D4 V
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);, M1 L- Q* q' `% ^
- pose.popPose();
. Z; D I. ?1 o$ Y) k" X+ p - }
* Z) q& y+ a: n, a9 b* p8 ^' ] - : f) T: ]2 @3 P" N+ A& M- u
- private RenderType getLayers(String texture, int light) {
2 Y9 U; q/ C3 f1 L9 \9 F2 k% \6 _* |, y - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));- X7 M) w1 m: L. K$ u' l! i
- }
. {% Y) ]7 j5 H, u" H& ^ - + z4 d3 m9 V7 w; {
- private RenderType getLightTexture(ResourceLocation texture) {
0 l# e# N8 s+ s( y2 b8 o - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);3 Q1 l' p* B/ |+ j) N5 T" v
- }
E( w/ f; V$ {9 G7 I
* d9 q4 ]8 i: A0 x- private RenderType getTexture(ResourceLocation texture) {
) j& V! Z9 F3 N& ? - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
7 e2 S4 _. i, P1 F. g! A$ f i - }: r" d8 D7 i# B4 }* V& }, r
- ) e* U) g: ?4 R" y1 W4 [! ]6 T
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
) l# y% Q9 i5 c3 `' D/ n - if (cache.containsKey(identifier)) {' E0 q' v, |- s
- return cache.get(identifier);: ^7 ^& ?, |# W8 S7 F8 U/ h
- } else {
4 ~( K) [+ o# ~& ? - final RenderType renderLayer = supplier.get();" p! R7 K$ M. G
- cache.put(identifier, renderLayer);
$ L) f8 n6 V# P$ m/ Y - return renderLayer;4 z% P/ V# e! ?2 L
- }# c' e/ A3 ~. G: u9 A! ?
- }6 h8 W: ~7 O; u* W$ ?3 \
- }
复制代码 |
|