|
|
2 } v$ T6 M4 d0 q5 u5 W9 q& [% U
行,这个怎么样
6 n! L9 G) L, m( _/ b5 c- package com.xhg78999.mtrfac.render;
4 ~6 Z7 P H. L$ A4 t - 8 k3 B3 t1 N, F& b% n
- import com.mojang.blaze3d.vertex.PoseStack;. H7 @- I+ b; N8 Y5 J( B, b! y
- import com.mojang.blaze3d.vertex.VertexConsumer;+ r( W* U8 Y0 C- S. M/ i8 P6 M
- import net.minecraft.client.renderer.RenderType;
$ [' E0 r2 a, K+ R - import net.minecraft.resources.ResourceLocation;) R" k* I2 ?% O. O- b6 b
3 B( M0 w: O7 |1 O7 k: h- import java.util.*;: h& z: r+ {* r+ Y6 X& O
- 0 q! v7 ?1 }# J8 D- A0 F
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(2 [5 M+ K# d2 Z9 p% f
- : N* X& H# S4 f
- public class LineRender{) |( @6 G3 q) K4 u" i0 u7 z
- private final PoseStack pose;
( `- C6 y1 F% B - private final MultiBufferSource source;
! O! K5 i/ G! E, d' d - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
; G: @1 q% {" D4 }1 f8 o - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();/ @& y4 b- Z' T0 X5 i! ]
. ^0 {; i+ D ` r+ X& b
$ q/ F% F' u* x2 E1 C- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){/ k: X4 `7 a% z
- if(x1 == x2 && y1 == y2 && z1 == z2){6 L' b/ `, B1 H" g+ c+ {1 C% K# h* `3 Q
- return;- f7 L' u, o h3 E
- }4 C. ^: s& F$ s" I# {
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){4 v4 D* L3 N0 d
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
1 B: ?& X0 p7 b9 C% G8 D - }$ X# A E1 a9 H7 C8 X" h- {( F
- pose.pushPose();6 y% g) O4 c" B) A4 d( Q: a/ [& k
- final int newLight = convertLight(6);
& w, R( o0 c5 v+ i9 O5 g - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
( t; _& {$ W% @" f# @" z( K# D( { - final float lineHeightSmall = (y2 - y1);
2 T2 E' x) u. c - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
" P: s- N% _% `. a; o2 g. @' t - pose.popPose();
6 }9 c3 } p* ]; U( S5 C1 M - }8 |) l/ |( ~) a% V! ~: @
: i* F8 x/ x- q; g- H+ S- private RenderType getLayers(String texture, int light) {, C9 T, I- W; P! S, S. `
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
# F6 c- n7 Y! P - }
* W% E8 j" C' Y. [+ L4 g+ [4 _. n
( @; I5 e2 O5 m( q# y- private RenderType getLightTexture(ResourceLocation texture) {
! g% M7 C2 s( W+ r3 S - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);1 J! a5 B: H5 ~: l% e+ `/ d# B4 v
- }3 h8 G+ j4 U+ B* q" j+ `9 a
- 9 b8 _9 x& b# p: P* d5 f4 `
- private RenderType getTexture(ResourceLocation texture) {
: _$ \) e+ Q/ T# \: M5 O - return this.cache(texture, () -> entityCutout(texture), CACHE_B);# k3 f @+ h' a; F( f [
- }
8 ^$ [& T$ {( ]/ l9 W& e - - ]) [: m* C4 m3 h J
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
9 s: u9 |& F) s4 |. X, n/ e8 `* c - if (cache.containsKey(identifier)) {. j, \. Z) K( P% X3 p3 n( I
- return cache.get(identifier); [, Y8 }. Y* }; f# G" G
- } else {$ e, [# `5 b8 w; I
- final RenderType renderLayer = supplier.get();
' h2 ~5 _/ n" C$ p - cache.put(identifier, renderLayer);
2 P s: E& f. M) R - return renderLayer;% x4 @' \) h. y# p6 H2 d
- }, v0 E# _- c0 ?% Z% G
- }* _; U2 Z% V7 b- z
- }
复制代码 |
|