|
|
$ |7 \0 ~' @0 ~行,这个怎么样
& ]# o. ^2 d( y9 w% u- package com.xhg78999.mtrfac.render;
; t. E! X1 M( P
0 T. }- W4 I2 ?# T- import com.mojang.blaze3d.vertex.PoseStack;+ G& b# V9 o$ ^. }
- import com.mojang.blaze3d.vertex.VertexConsumer;
8 ~0 `" l- V5 u# U9 X0 f( p( [ - import net.minecraft.client.renderer.RenderType;3 G2 r3 ]3 t( O8 q
- import net.minecraft.resources.ResourceLocation;
3 D2 R$ @ U3 Q1 {1 ] W" J$ H- F% F - 2 d3 Q. p' W- R
- import java.util.*;
6 U& F% G0 u9 J
5 M4 x7 v) n( [0 `5 G- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(1 G, U7 H& `" p" X$ R! J) ?
- * p9 C0 h ?. ^% I
- public class LineRender{* L% w% O9 ^7 `( T$ k. h
- private final PoseStack pose;2 n: {" i1 T# }) |2 _3 Z& n2 S
- private final MultiBufferSource source;4 N, H9 t) q8 a+ i$ [
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
f9 U2 f$ |; x+ p: C - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();- }- O# f U7 W6 E) o2 C. F. B
- 9 n* w4 Q: p5 Y' C0 z
& r; u. U; S$ j) ^- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){8 }8 I9 F$ v1 L5 G7 |5 e/ N
- if(x1 == x2 && y1 == y2 && z1 == z2){
2 R6 P0 X' A9 K `: n2 c' x - return;
R* t! X1 i. m# { p# } - }3 w) y6 q& m3 x: W5 C- l0 q; r3 H8 I9 s
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){, @0 D4 g' n w- v4 J: H* `
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
. p8 K, w" ?% A! q9 J3 Q5 t - }# N! n; s {. N) w! p
- pose.pushPose();
D1 F4 [6 `9 _) N5 y - final int newLight = convertLight(6);
- r. p, n+ ?$ m, l) Y" g! [ - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
9 _0 o) i' }& z/ z8 I' A' H - final float lineHeightSmall = (y2 - y1);
& {' t0 D e3 W0 X" H2 [3 k - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);5 G# C$ h+ P/ N" O
- pose.popPose();: ~' c- c# {. N& E* p0 w
- }
# z" V; ^6 R' m* C/ c; j+ N
% M* w, e7 a6 W) E# _+ f+ I- private RenderType getLayers(String texture, int light) {
) P3 j# }9 a& O2 A+ f0 l% u3 |3 l$ \ - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
0 [9 s2 ~8 _) `8 D( X - }
+ e& q p8 I, {6 D1 I - ( _/ K) g2 ?: X9 R: @
- private RenderType getLightTexture(ResourceLocation texture) {
" K6 s7 b8 j' U, a& D/ e2 C - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
+ P1 [2 B0 l* }; n4 H& B {2 y - }
5 H+ j- e o- @) b - % q6 J& k8 \# I; m& F, T( n+ G
- private RenderType getTexture(ResourceLocation texture) {2 R% I; {/ _" v' y
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);4 z( F+ ]8 a' M- \* @0 l1 A8 `; u
- }
! o0 w& Y" Q8 f! Y% h2 A4 X% C - 5 I. w4 l! _2 G
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {$ |. W L. W; s# C
- if (cache.containsKey(identifier)) {! D, o: F4 ? H% X; |; q5 Z' |
- return cache.get(identifier);
( r1 d, ^5 s: C* Q. ~2 Z, k - } else {$ E% @5 R/ \( z M
- final RenderType renderLayer = supplier.get();
; }- L1 B% `. h9 A - cache.put(identifier, renderLayer);
% E8 V6 Y" @ U* `" i2 K& b+ W/ r - return renderLayer;3 b1 p; F( ^' F1 o7 r" i
- }% ~% F+ X$ O6 @0 e: }8 O
- }
1 L: W, I3 |" Z A8 Y; [3 Y - }
复制代码 |
|