|
|
( [1 Z. K7 ?& \2 m. s. C
行,这个怎么样4 U2 [, V1 ]" L6 z* |: J. J I! N
- package com.xhg78999.mtrfac.render;2 ?: N+ Z+ a! {0 ]/ [# r' i
- ; `4 G! I! k0 z! n% b, s' k7 }# w8 O
- import com.mojang.blaze3d.vertex.PoseStack;: T E7 @, L" p1 ^& x2 s
- import com.mojang.blaze3d.vertex.VertexConsumer;7 F9 m# z$ u; F6 k ]5 ~
- import net.minecraft.client.renderer.RenderType;# ?( l7 E, f/ f" o4 m3 l' R. V6 x
- import net.minecraft.resources.ResourceLocation;
. `+ b8 a7 [3 L) u4 P - ' ^- q* D+ ~6 {: g# z9 u
- import java.util.*;! q/ ], v" y# E* ?: {5 G5 Y- C
u/ N+ G' ? B- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(/ ^( }4 X; g4 N
- u8 u! H1 s: b& N4 {6 \( ~
- public class LineRender{
* z- ]7 }" j6 S+ S/ T- Y - private final PoseStack pose;1 y' Y5 x) |' m# x2 ^ q7 j
- private final MultiBufferSource source;- U6 s7 M5 N' t$ s# f) r
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();: i) ~* ~1 z! D7 j# @2 ^2 x3 M
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();8 j+ ~" }( @7 D+ |2 \1 |
- : m @, i0 z) e6 }2 O
- 8 c$ @; {4 t3 R' m" L# l b
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){; ^* E. j b' }+ k$ r
- if(x1 == x2 && y1 == y2 && z1 == z2){
5 y! l% ?. Y/ p9 s! D3 l - return;/ n2 ?- H9 {5 u/ H- l0 Q
- }3 D; J# @8 e( p6 ~* c8 J
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
+ O/ u4 L1 `1 M# d9 \% l9 ? - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");( j: W# y3 f, s6 Z$ K' B# U
- }
y* `) }- F6 I0 b8 t - pose.pushPose();$ F( d. w" X9 e: E
- final int newLight = convertLight(6);
; ]% z3 t% D3 n1 w. @5 x- `. b - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));3 h% P% |- N ]0 p4 ^
- final float lineHeightSmall = (y2 - y1);; N1 J+ D! x' ?
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);5 F- y. H) e5 b+ J
- pose.popPose();
, |+ h1 J) v9 ~2 U, K+ A1 E - }0 q: ~, N8 V$ X" _3 F& ~7 u
- - s: s2 T7 r0 N$ ^) c% x" ^! u
- private RenderType getLayers(String texture, int light) {
) ~/ M$ |8 j' x2 `( Q" {8 X6 G - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
/ v J' p8 z9 I/ h! C; L+ _ - }
1 l# T0 c$ n3 G4 `$ q( w
; l. y9 L$ g0 _/ h- private RenderType getLightTexture(ResourceLocation texture) {: K* }' m0 A C
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);8 A2 Z, n$ D; K/ m
- }1 B" h: [8 H9 y x, B3 `2 }
# V* j2 T6 m: R8 r- private RenderType getTexture(ResourceLocation texture) {
% n5 H5 o$ G* {. C( Z: E3 y - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
3 N: l n4 K3 k- Z - }
" h2 g/ D- `5 C% V6 s9 ~% ?
2 { B. G8 l# e6 J+ y1 |- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {. f! {0 C) k) g- t3 K
- if (cache.containsKey(identifier)) {0 r7 ?1 y' g& [" Y7 ~
- return cache.get(identifier);
9 ^" G9 i+ T/ q, o l2 @) q! w - } else {
S5 \4 X! v: n( {4 n2 a7 g+ A - final RenderType renderLayer = supplier.get();2 Q7 {. C, D' `9 Y# V5 D0 }
- cache.put(identifier, renderLayer);
2 O0 e# W5 [+ k' i: N+ g - return renderLayer;# y& p: f1 U" B8 d0 L. b
- }
0 {& T7 i0 k* \. V" U1 s - }$ f$ H4 `! K G6 X
- }
复制代码 |
|