|
|
# J4 Z$ c# I) v( [5 {# N& {; m5 h
行,这个怎么样
/ {3 |2 V; U! K# a1 ?7 R- package com.xhg78999.mtrfac.render;$ {/ p1 g0 r6 _. I
+ b: I5 H9 f7 V- F5 K, _1 C- import com.mojang.blaze3d.vertex.PoseStack;6 L( K1 j3 ?; A0 O3 A/ u
- import com.mojang.blaze3d.vertex.VertexConsumer;! t8 O# W# G3 }; h) u' ^# e. @
- import net.minecraft.client.renderer.RenderType;5 y) s5 P: t+ O' l4 d8 k6 e( ]
- import net.minecraft.resources.ResourceLocation;
, J8 j) ]* [, |& e, } - 8 O% R. t0 [0 ?. ?
- import java.util.*;6 l* N1 H7 @7 c
- 5 g2 t3 i/ \/ v
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
. v$ C! o0 _ r7 s" p# j7 @- z0 L
* l8 p: D: }$ k8 H- public class LineRender{, ~# ^0 A, y+ ~8 f L. K- ~
- private final PoseStack pose;
3 F# p/ n: C+ P8 d - private final MultiBufferSource source;* [; n$ t9 x. _3 s; T# A$ }! o P
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();9 C( ^7 e4 T, n% B! o
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
5 P: C! W& N3 d& D6 ?
8 s9 `( g: @; h7 I! q8 |7 _/ D- 7 N- W7 x% e% f& A
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
+ e4 ?2 s {/ }0 \ - if(x1 == x2 && y1 == y2 && z1 == z2){
) O1 d8 W3 m* ?% f7 V! w7 j2 r8 k - return;4 h \# y& H, b- W" D
- }6 r! X2 h% X2 P1 p
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){( C* \6 ?/ V- a2 G8 C' q; p
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");1 D5 d+ v- }; W' c
- }
# S, X8 [- j7 M& y* u k - pose.pushPose();
. n6 R. ^. x( v7 s9 d) s - final int newLight = convertLight(6);
4 i( R2 G- J* t - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));: s8 t r8 p. o2 Q6 r p
- final float lineHeightSmall = (y2 - y1);
0 ^# b8 s* s/ ~* Q - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);/ ? e4 Q& Q( @ z- w+ v
- pose.popPose();! b& s* m% ]" G1 w3 I: C. P! [
- }4 h2 Z+ p$ i2 v" j1 l% O
; @" h2 W% ^8 R% q4 J" r! z& n3 e- private RenderType getLayers(String texture, int light) {
* J4 M/ i6 F% d' c3 Y, \7 w( ~7 J - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
. T, T, N7 w. d W" A7 `9 N: s - }
' R( O- M4 D5 h9 ^3 E
8 A0 C0 z5 M) G2 @4 K- private RenderType getLightTexture(ResourceLocation texture) {
0 k# Y& d& G; N. ? - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);- U/ q0 }) u/ r3 s4 k* G9 K4 I0 o
- }
5 v5 w9 p9 K! S4 U7 ` J: ^6 u- c - . O( c( H$ p C. r; h- |
- private RenderType getTexture(ResourceLocation texture) {" ^9 z$ J1 y( i
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);# c) q5 g. S1 I1 @; h
- } k; ^# L* q2 ` [
- 4 B+ m' p+ ~) S: m; L- D$ l4 @
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {$ Q w9 [9 Q) G7 e% K
- if (cache.containsKey(identifier)) {; C0 I) L5 o8 B# X# i
- return cache.get(identifier);7 O* |/ l) X% m& Q& v$ R
- } else {
7 N5 f; G1 |4 y, ~/ S - final RenderType renderLayer = supplier.get();1 b9 D- S$ L* Q9 F8 c/ W3 S# S
- cache.put(identifier, renderLayer);
' k L7 r' S, r) V" J, d3 D: i - return renderLayer;4 \. t5 |1 P) ?: H
- }
+ q5 D( H2 f7 A - }
5 U7 b" j" d# T8 l2 P- [' w# l - }
复制代码 |
|