|
|
* G: v/ N" Z( D- l, f/ W+ }
行,这个怎么样
4 B6 s+ n/ n6 x; v& R# c O% [- package com.xhg78999.mtrfac.render;
, q: K1 E; N; V: t K3 W. t0 G$ Y9 ` - + w I( ^( }8 Z9 `
- import com.mojang.blaze3d.vertex.PoseStack;/ m0 T$ q( X1 ^7 e
- import com.mojang.blaze3d.vertex.VertexConsumer;9 }% w- [/ Y% i
- import net.minecraft.client.renderer.RenderType;
. g I4 t, R9 H% q! h, i - import net.minecraft.resources.ResourceLocation;
2 i8 n2 q& g" B8 H9 c, Q, R
- h) I! b4 d# S! Y$ I- import java.util.*;
" D) P/ K$ ~; Q/ M3 O( M
5 D# K. n: n" f, {, O; z- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(# M& d/ e, O+ k- r" N
- 9 Q d. C# N$ [
- public class LineRender{
/ ]+ D: E/ ?$ l; ]- J+ k - private final PoseStack pose;& B. Z& n3 v7 F# k+ |/ E6 B
- private final MultiBufferSource source;' p* \6 n6 w4 X5 N% `/ N5 l
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
& C# o7 E0 Y$ W - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();9 `, |. c2 h# q! f
2 l' t6 V8 M r" E3 ?0 O7 Z" O- 2 d7 f& R) o ]+ S# \9 s
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){, p2 a0 z+ _0 y) c7 k
- if(x1 == x2 && y1 == y2 && z1 == z2){
" D/ t; X" Y- R - return;
s. j% q6 ]& j3 i6 ^ - }6 R& x) W \- ?
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
2 ^+ W4 M3 n1 q1 P% q - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
: O8 K& n9 u4 \- Z1 l - }2 a5 D* @: D6 X0 K w! X
- pose.pushPose();. A8 f! j% e! K8 l
- final int newLight = convertLight(6);
) z: m' J0 o) Z& G9 B) Q - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));; C3 A( a: }7 {& R/ y4 c
- final float lineHeightSmall = (y2 - y1);/ T. B) n2 J# B% v% B
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);9 Z0 [9 L. f0 T r+ ]9 z+ W
- pose.popPose();2 G# ]. Z' }. _" e( \( i( A3 y' ~
- }
8 J% ?" {$ D: m; X
* S, D1 C3 m( r& C0 L- private RenderType getLayers(String texture, int light) {
1 p% `+ T/ V# r - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));) U. \* G. N9 D$ [5 \
- }
3 S% v1 J1 B2 j7 G+ `* h9 \ - 4 {; T$ P) O! z2 M8 y
- private RenderType getLightTexture(ResourceLocation texture) {
( H4 i3 Z9 h% m h5 r - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);( \- |9 X' ~( ^+ c& k
- }* c W- b# u; _+ C
- - @. l2 |8 f; n# K9 P+ R% g
- private RenderType getTexture(ResourceLocation texture) {4 X/ K, O Q6 u+ a
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
3 z& O5 F- ]: ]& w - }
( U4 O% r' z7 X6 i
2 u7 s* t1 @9 Y$ ~: a, K- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
' k @+ J: y$ H0 y) `7 I - if (cache.containsKey(identifier)) {
" C2 I3 T+ X, H - return cache.get(identifier);
, W: P4 i5 H3 A9 q - } else {
# M9 J. b2 g$ D1 { - final RenderType renderLayer = supplier.get();& u- \: W& ?8 F. T A
- cache.put(identifier, renderLayer);4 f7 `. b+ F; {% q K, ^
- return renderLayer;
+ b0 s2 G- } d. C - }
* a* X9 w% `- a2 c - }+ ?1 [7 B# z6 r+ i
- }
复制代码 |
|