|
|
- @9 {' o, q8 Q/ o8 N4 z行,这个怎么样
. l" K. _# }. ?- k/ t/ Y) W- package com.xhg78999.mtrfac.render;0 c X3 M; n+ U
) T1 Q u7 J5 t# d+ f! y- import com.mojang.blaze3d.vertex.PoseStack;( z; ^& Z9 A9 h) V% f
- import com.mojang.blaze3d.vertex.VertexConsumer;
& C# q. T6 v+ u* x5 m7 {* q# O0 l - import net.minecraft.client.renderer.RenderType;" m1 ^: H. f1 J. N; e5 j* t7 S
- import net.minecraft.resources.ResourceLocation;
! C+ j# x) i! b) { - ; D0 N7 b* } k' v+ V& }7 @4 M
- import java.util.*;3 [; m" ]" ?4 \) Y
- ( l, Z: w" [: V
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(* K# G, l9 Q% b2 `
- % H" k* Z5 L+ K7 e
- public class LineRender{
+ c& a' k: d- C0 p0 A - private final PoseStack pose;
$ Z. A h1 G' j8 D2 V8 v9 b: } J - private final MultiBufferSource source;
0 ?0 W1 w6 B; M4 `* V: x - private static final Map<String, RenderType> CACHE_A = new HashMap<>();" k! d7 ]/ _ Z3 r
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();, m, o, j4 l$ v5 u* A6 W3 D: m# d
1 N, \3 V3 X( R8 f. w' m
4 d1 u, E. Y8 A, K% t j j- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){- S z7 T4 x. g1 y @9 j7 ]
- if(x1 == x2 && y1 == y2 && z1 == z2){ O% u6 u9 T. y# z" E: c
- return;
C, X4 r3 _& _. T0 J - }
; |6 H, ]! ]' \- Z9 f - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
7 [$ Q. b+ D9 j7 d4 E - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
, a z9 F5 z# i$ a3 L& b& j/ U - }
2 m# y4 J- S' d. ~0 ?% ] - pose.pushPose();
# s+ }1 Q f6 x - final int newLight = convertLight(6);5 [5 |9 ?7 B" y5 n
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
5 X+ B/ [+ T. |% r$ Y8 x - final float lineHeightSmall = (y2 - y1);. x4 q+ y8 g# Z2 N4 W( F) v2 y
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);. o7 O( [$ r0 U4 _0 I
- pose.popPose();
* u) a; t) M6 ?' s - }# Q2 }; @1 T# R) F. H# l
- 8 e/ M- N8 X1 |/ j& q3 [4 I
- private RenderType getLayers(String texture, int light) {
5 }6 K5 `2 p2 Z9 O9 s - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
7 z: g' T) p& r! c0 d+ H. s4 A - }) X8 U5 P A1 i% w
9 o0 ]+ r K) w* N% E- private RenderType getLightTexture(ResourceLocation texture) {
/ q+ f. ~# q! i. Q, p# }* f1 @3 A4 R - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);* b* V$ J0 w& Z r4 v: U2 @
- }6 f1 l+ K( u: S. M/ z& n7 u B! }
- % X# w3 k% X6 Z( Y8 h4 @# H
- private RenderType getTexture(ResourceLocation texture) {
* a% `' F0 U2 U# {# h - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
- N- ]' J- `- h4 I+ P( r: Q - }
: Y" C) T1 v, R1 ?9 \2 {. s
- g, j* V+ s. E0 q+ e; m- A- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {4 J1 ?9 Q; L$ Q6 t8 U
- if (cache.containsKey(identifier)) {
6 X* D" j6 V" }4 r4 _8 \ - return cache.get(identifier);! s# ~+ {& q: l- N
- } else {- R0 @ N- e; r+ O
- final RenderType renderLayer = supplier.get();
, }- y' H5 R1 }9 \2 O4 H" o' e" F - cache.put(identifier, renderLayer);* g6 O( t9 `# A1 e! I
- return renderLayer;* P, u a5 n$ H/ z5 b1 l% ^
- }) _% ]( p, e ~- o" {! \ A
- }) M0 _' }5 T$ O, z8 L
- }
复制代码 |
|