|
|
$ {# [1 V; q5 s2 W9 C6 r行,这个怎么样
q" Z* ~! D: n7 n+ d- package com.xhg78999.mtrfac.render;
" [" H0 B3 W& t, m - ( V m4 q) h2 [
- import com.mojang.blaze3d.vertex.PoseStack;5 D/ [2 F- e) N% Y5 @1 F8 C" E" I
- import com.mojang.blaze3d.vertex.VertexConsumer;
' B1 l& ?* l1 g - import net.minecraft.client.renderer.RenderType;
/ O: U5 ^ \, S) H; ]6 R: q M: ?" F - import net.minecraft.resources.ResourceLocation;
, b& Y3 Q* x6 Q# ?* N9 `
9 U5 w3 m( V& W+ |$ |3 g- w- import java.util.*;
. ]& n! I5 K* H; L7 Q+ s
% l: X5 C! h: @' D- A7 c6 b8 R! j- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(8 Y. K, ^1 n' W' r% ]+ W
9 n6 ]/ C$ O* s- public class LineRender{, |3 z3 u( H2 C- y3 f/ F% F
- private final PoseStack pose;
/ G0 C* }4 A) ?8 u6 Z8 y' x - private final MultiBufferSource source;3 Q! p$ U$ Z! ^7 w7 k& F; r
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();. }+ S& }' ?0 z: s* \% {
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
2 W; o% _8 G: s6 ]: X T
' P+ d5 x( y7 o$ q- 6 a- c4 a1 ^5 D, d7 x+ `" B8 _
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){% |2 k- _5 D7 n2 ]4 {, a
- if(x1 == x2 && y1 == y2 && z1 == z2){1 e' J1 b2 F# _% a- s5 v
- return;& J# T% |- K# U0 O! C9 O
- }
9 ^; k8 l2 v1 O$ h ~" W - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
' V/ T$ e% O! x3 w% H2 {9 u3 _ - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
1 Q# v9 C9 y3 D `; C3 { - }
0 C; `. L ^6 p+ K Z# n( ? - pose.pushPose();
4 }3 ]' {! I% d6 c) a - final int newLight = convertLight(6);
, D, _$ o7 i: @( O2 I9 ^; Q: [5 T - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));2 Y1 i: x# r' X6 u( S2 X4 @- Q
- final float lineHeightSmall = (y2 - y1);# A v: H5 M" [/ w1 U( Q
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);; {% y. s. }1 z. H% r6 P0 V4 [( C2 ?
- pose.popPose();
: d9 U# G1 z: |$ T' X! B - }: X% m+ _% ~) {2 y# S
: z2 @+ B' H4 D- private RenderType getLayers(String texture, int light) {9 p" j7 Y4 J- {2 p: U. Q
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
3 w3 Y' d5 d O Q+ j( W - }
& X' i' m6 y+ {+ r& _ - 0 c5 Z3 X% \! I4 {) X1 P, W" v
- private RenderType getLightTexture(ResourceLocation texture) {. m2 V/ l. o9 c. h( V: R6 l P4 |$ W
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
+ {) i- q. n4 H2 U. R, Z - }
* `/ H% r$ ~- b - - E/ h" l# _* ^' [5 J6 y
- private RenderType getTexture(ResourceLocation texture) {5 F2 |" e2 L- S5 r/ V% i1 e0 t8 B- G
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);0 ^# q' N; o- U# }" n+ g
- }* | M- ~- l; F6 p
* J* [' @1 x/ U3 [- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
3 [' g. I' T! a: @: s* g# t! n- I - if (cache.containsKey(identifier)) {
4 C! E. b" k6 [0 m9 R3 a- l7 L' l - return cache.get(identifier); v+ R6 x C4 Q# P R! V
- } else {' [" O' }/ E0 E R# U. P* `' ?2 w
- final RenderType renderLayer = supplier.get();0 w! x1 q/ P+ `% \( B
- cache.put(identifier, renderLayer);
k9 R8 o0 B& Y9 j( S: { - return renderLayer;
1 F0 N7 W7 m" X; H. P& ~ - }1 \/ J* s: f/ }2 j
- }
% U0 a5 K% h. j2 I/ Q2 \5 k - }
复制代码 |
|