|
|
* o w) ` v& z
行,这个怎么样2 i4 ~7 L7 B/ @7 {' N: m6 t
- package com.xhg78999.mtrfac.render;* A3 o; F3 x$ W; K4 C# {
- t+ E' `& F7 k$ t
- import com.mojang.blaze3d.vertex.PoseStack;% W* B3 i* l' J$ j3 L4 G
- import com.mojang.blaze3d.vertex.VertexConsumer;) S* u" x, U X1 j
- import net.minecraft.client.renderer.RenderType;" W9 {6 a; [" g2 g
- import net.minecraft.resources.ResourceLocation;) O; j0 t: B$ o% U
- ; z6 s+ N- X7 x2 i! T T* m8 F
- import java.util.*;( r% l+ h& O. K+ v, H6 J' [
5 D6 g: h$ e8 }4 ~- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
, R% b3 t/ Q' o; V& T# H - & m+ E; C* X N' P
- public class LineRender{ R- Q7 F3 U9 m9 r+ M% z
- private final PoseStack pose;
2 G: x# c) P ? - private final MultiBufferSource source;2 L6 A3 c/ l3 o5 ]" V
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();$ P! ~7 m' W% n' d7 L, `/ Y2 `7 t- E
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();- A+ K& d k" o3 J, P. F$ H% C
- + z, \6 Q+ d& s7 }/ \/ k6 {
( C" @6 |+ c5 w) O, ~- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){9 [! P7 R' q9 _$ g2 |
- if(x1 == x2 && y1 == y2 && z1 == z2){4 U% n) m* m: T. h2 m
- return;8 ~# r* I1 v# Q5 l% s* ]
- }" ]% i" c6 V8 s/ l3 V8 t
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){* }, {& k1 D; d5 G# j
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
% E2 r, T/ a4 ^ - }
0 H4 f* c3 U' u - pose.pushPose();
$ \5 U0 S" e' m8 b& [4 v6 |' ^ - final int newLight = convertLight(6);0 Z8 ]; D2 v- t+ C
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));) l, h' `0 b" k
- final float lineHeightSmall = (y2 - y1);# Z) Q6 ?3 K3 y/ I
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
5 S: p2 n/ Q0 T1 G& b: t- |9 h - pose.popPose();7 @0 u5 H2 o. B; z5 y; V& M
- }
& u; [% u9 K% T/ ]+ U( K3 | - % j' d$ D/ K- F9 |
- private RenderType getLayers(String texture, int light) {* u$ O. n: V" ?7 k- y( y- \0 X
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));6 B6 R& \" \- h2 M) u
- }0 E) v5 h) S/ ?7 D
- X+ C6 K* z' D4 o& o6 {
- private RenderType getLightTexture(ResourceLocation texture) {/ A" q' w$ p+ A) y, I# g: b$ w
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);7 G) x$ z( U8 Q# ]- ~. {% o( \
- }
\( X( Q. |0 H& T- p! z# } - * U2 y3 f4 ^, s, }5 \+ H
- private RenderType getTexture(ResourceLocation texture) {: {* {& e9 o3 p) ^
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);3 |6 n f4 j S
- }
) |8 M; E+ O. i- s& i
. Z Y6 l3 g( V* L. B2 U# I9 C- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {0 W3 s( I- g/ D
- if (cache.containsKey(identifier)) {
: P1 |* L$ C& C. s y: W - return cache.get(identifier);# g7 h0 c& U |/ J; F
- } else {* m, }& |3 b9 P6 G6 x: e- `5 ~
- final RenderType renderLayer = supplier.get(); l% X1 K* r# c2 m6 ]
- cache.put(identifier, renderLayer);' X9 A+ ~9 w8 f' D
- return renderLayer;
: K; B# v3 y& {. G' W( W - }
: g+ g# P, q! s1 R1 F& z - }
: B7 I! X4 o* c1 K" a2 b$ n - }
复制代码 |
|