|
|
7 J# P% ?' z$ f t1 O4 L1 c3 y0 E
行,这个怎么样
. x. Q, {& g6 j% O) ^0 R- package com.xhg78999.mtrfac.render;
4 F3 W6 R+ Q2 n7 W v! E8 q' B/ j - ' b! k5 p2 r7 Q+ a7 d* z, s
- import com.mojang.blaze3d.vertex.PoseStack;& J5 z, Z' w* V, E- I
- import com.mojang.blaze3d.vertex.VertexConsumer;
+ v; b2 X$ p z. [+ R' O; M - import net.minecraft.client.renderer.RenderType;
& n' ~4 e% E) t; Y, ~ - import net.minecraft.resources.ResourceLocation;" F: d6 e4 y0 M. a2 O2 \
- 3 n; B+ h" ]6 \+ a, O$ @2 Q
- import java.util.*;! A4 ]0 C8 S0 C% H: c' Y6 {
5 w; C: t# y+ n: e) Q- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
* y+ J& P& Q5 p/ r, m) e- W
4 k& B+ O" @2 }" c# b- public class LineRender{
4 D+ R* K* N7 ~5 l - private final PoseStack pose;
& ?# i6 |6 d1 R; a. L6 p - private final MultiBufferSource source;
* x# G4 D3 `5 [1 f, B - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
- h. t; m6 ]8 }: e3 W. X - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
; ^- P9 y, _, a/ |* H5 e - ( F. V: {/ [3 L
. E& ^1 |/ e1 X' K- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){( a$ }/ Y) }; z- H
- if(x1 == x2 && y1 == y2 && z1 == z2){
* R, b+ c' \6 u& S4 v. H6 x+ K' q - return;$ k. Z9 ]& h+ _ }. l7 N7 J' G1 A
- }, [! Z0 _7 M& s* R, w
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
! x! J" O% t0 X" ?: \( j! z - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
! x) U) C5 y& U - }
% b, m0 u5 e( [+ e" Z. o; M - pose.pushPose();. C, a$ i0 z8 v& n2 Y
- final int newLight = convertLight(6);, u, P( p7 h! ~+ o+ q& l
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
/ D# @: F# B+ l, r - final float lineHeightSmall = (y2 - y1);1 h3 T$ l: a5 S6 W
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);; y" C9 T' p8 y0 C
- pose.popPose();
: g2 V3 w, }: j+ D; ] ?) X& B - }
) E2 U6 }3 H3 b5 _$ ?
; Z" d, H! u! T4 c Q6 T- private RenderType getLayers(String texture, int light) {* o/ g/ f% S' @5 _& A: [
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
$ O3 [/ ~) l2 A V* @8 d4 S5 B - }
5 y( }; q o& m# f0 H
' h( D. \$ e& n- private RenderType getLightTexture(ResourceLocation texture) {0 S" a: _! v# z0 x9 N1 b- m c
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);2 x* [& d, N3 \! L8 a0 a
- }
% O: j3 D# ^' A* A( Q) e. O6 k
& N% k* g3 C% g4 g: h) s- private RenderType getTexture(ResourceLocation texture) {
3 R5 s Q0 z: M, i1 R - return this.cache(texture, () -> entityCutout(texture), CACHE_B);( ]- ^2 Q/ ^0 z5 a0 |5 c6 |
- }
0 p, S/ x# }/ h: O. W" e - # t. w( ^/ ]1 f( m. J1 D2 f
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {1 m; d* }4 E7 w, n
- if (cache.containsKey(identifier)) {
1 ]1 m6 r. } P# Q - return cache.get(identifier); l. A; w4 z* b2 |
- } else {
8 S! o- T% Q, V0 l+ }. w+ T Q - final RenderType renderLayer = supplier.get();
6 C" I d2 o I( d; U7 F - cache.put(identifier, renderLayer);
, p% l' @5 O7 j - return renderLayer;3 k" }6 `1 a; r9 q% L' j
- }
: Y1 y1 J# p+ q1 p - }+ z% y( _/ Q, |4 o
- }
复制代码 |
|