|
|
g' ?/ I) H) m
行,这个怎么样+ x& M! Q% H( H' g" J4 n: \: Z- V7 |/ y
- package com.xhg78999.mtrfac.render;/ l( I. D4 }( e, V+ t% W6 L3 g: f
& i& V0 Q l% p6 d8 u- import com.mojang.blaze3d.vertex.PoseStack;
& G% n0 c" _* U& I. u- _ - import com.mojang.blaze3d.vertex.VertexConsumer;
5 @( m: O( Q9 y8 C3 m- r - import net.minecraft.client.renderer.RenderType;
$ @2 B- z2 M6 r$ l# m, a# M - import net.minecraft.resources.ResourceLocation;
. t1 j* [: T7 o9 r c/ l( [ - 6 i" H6 W! W" t
- import java.util.*;
; o* ]$ V7 q$ O$ x" c - $ ?' F( m) ]9 m2 t% P2 \1 V/ A
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
8 b0 `" _, z# v7 [ - . ]7 R4 W; t+ F4 \$ O. L0 R
- public class LineRender{
/ R! l3 Z0 T7 J - private final PoseStack pose;
n% N! r7 o& U( F( U! |% i! T - private final MultiBufferSource source;
1 g" B/ s# u8 X- a - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
) B5 T( C' u/ H0 }8 A - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
K" o; N2 `* b& a
3 H: x1 o' }; Q! D9 K$ E5 ~
" K+ d6 `6 D( \/ M* o( c- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
( g- {# w' H- W# q/ q) J - if(x1 == x2 && y1 == y2 && z1 == z2){% ^4 { }8 }1 l& M& G
- return;
& T1 V E3 A s2 F - }8 D" d. i6 X: e2 @9 z* T9 S( j
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
3 H8 `7 _. T$ {5 N& g - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
* L5 b- _9 X) U1 \ - }
- i O/ M6 N! c3 h& F- i - pose.pushPose();" g0 V) ~/ A. x9 r1 }
- final int newLight = convertLight(6);
7 X5 ?) @4 ?# k) Z$ s - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
' O2 K7 l" T! {( \$ z$ l7 n - final float lineHeightSmall = (y2 - y1);
4 |8 [2 B4 d9 ?- J. e" K% a - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
, ^' J3 \, J- s0 S0 C - pose.popPose();- T% H& j7 g3 s- Z/ b
- }
4 s8 k1 ~# l% B - . H( F! C$ R% x( v% G5 N& L# Y
- private RenderType getLayers(String texture, int light) {) C4 G F* u& m' o, [
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
d& G* R8 o6 l/ }0 | - }
4 }* M* b. e7 j: |9 ~' ~
2 K# B' x- h( F- {( c, J) r5 c9 ?- private RenderType getLightTexture(ResourceLocation texture) {
' U( V! S$ F) l& g2 m - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
$ t2 r3 Y6 f6 n2 ?- A$ t' c - }
7 q' K$ { P, B" R& x+ W, q - 3 j! ^- T4 v* H$ I2 n7 Z
- private RenderType getTexture(ResourceLocation texture) {
8 D f; G4 J8 L) l6 F - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
7 Z2 w$ l; b! w3 \+ P - }
' i/ o4 b0 X0 S9 _4 ?5 p9 B4 V
$ p: ^# H, W6 o, I- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {: ?. T2 L# X1 y0 p b9 u
- if (cache.containsKey(identifier)) {% D8 A" a9 {4 C: W) H
- return cache.get(identifier);
1 @" g, T8 i" e3 t - } else {+ V$ ]$ N* Z; {4 z- o
- final RenderType renderLayer = supplier.get();+ x) O. W$ f! {/ T/ _3 C1 g& {8 L; `
- cache.put(identifier, renderLayer);
/ X' [2 \4 `# k& t Y: x( J7 a - return renderLayer;
( B" I1 [# t; u/ G9 i- F8 y; q - }
+ r, m( c4 a% ^( D. j - }0 V4 E7 v7 @4 }* ~
- }
复制代码 |
|