|
|
" C/ c1 A8 N2 l行,这个怎么样
+ c9 X* O9 Z& d- l& F. C- package com.xhg78999.mtrfac.render;: Y- T: y" {! }1 ~: g3 ?7 W7 m
2 `9 k2 I3 w4 U8 f6 S- import com.mojang.blaze3d.vertex.PoseStack;
7 C) a( | F( X1 l - import com.mojang.blaze3d.vertex.VertexConsumer;5 S: X3 M$ d1 v2 B, N5 D( E% T6 h
- import net.minecraft.client.renderer.RenderType;7 D* ~, V; P, Y, t; {/ D/ r" ]. v
- import net.minecraft.resources.ResourceLocation;5 u, c8 s# M6 M
3 Y' K) ?; b- Y& s' F+ Q3 c" K- import java.util.*;2 \, K6 J8 m& A# e8 K0 w: x. |/ }
! L$ I7 H* L! z8 R$ l0 M- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(; `- d( J6 k2 }) D \& y- r# u
- ^& ^; r- Z. r9 ^9 T- public class LineRender{, R% v ~, K4 S! ~" \: \" c
- private final PoseStack pose;; h8 R& C1 F, y; j2 o' a% n {4 A
- private final MultiBufferSource source;
4 H2 ^* Y# m( A f3 f) U) k - private static final Map<String, RenderType> CACHE_A = new HashMap<>();+ K0 z3 E6 ^' @% [0 u/ M
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
, j0 k3 b" L, a6 P) B
$ @$ L/ C( c. P8 [' `! J
, s4 a4 B, K3 |7 F6 y- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
) V K) d( u4 h, k9 m - if(x1 == x2 && y1 == y2 && z1 == z2){
4 g; Y. X, w1 l1 |/ g - return;+ d% J- p I7 K4 A$ W, ^1 G
- }6 E" y1 K, k. S9 m8 r
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
1 n3 X t8 j4 H/ }; h) @" K - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
6 \ Q8 N4 l0 z1 w! m - }1 i: g- {) t! K+ i
- pose.pushPose();
4 n8 F8 V/ ]) I3 N, | - final int newLight = convertLight(6);/ T" b/ W$ V" q( `+ v
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));! j6 h- t4 R' E
- final float lineHeightSmall = (y2 - y1);
" |' [* i$ k8 k( e$ z+ N& s8 o - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
* F) H; a4 ]; K' |8 I. [, U8 T - pose.popPose();
" Y& G3 c3 k2 d% `; f' G$ W+ @ - }2 f: _2 F, m; w
0 e7 ` J1 b1 q7 d# g% e- private RenderType getLayers(String texture, int light) {
5 h5 b8 s: S2 `% i0 Q! n4 s) b - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));9 Q0 d3 `9 V% @2 K* q( \: F
- }
; T5 d3 z. }$ H7 U# [7 ^# r - " f) r* O" K, n
- private RenderType getLightTexture(ResourceLocation texture) {8 D/ R3 K" e( |
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
2 |' R; Q" I" `+ q - }/ I% ]! m: {4 K( a3 i# x
- ' I8 ?4 F6 P/ I
- private RenderType getTexture(ResourceLocation texture) {
8 R7 d3 Y4 B/ r% t. A4 W" l - return this.cache(texture, () -> entityCutout(texture), CACHE_B);: s9 n5 _# K/ w1 U4 h
- }
: S3 ]% Y8 ^( ~ G4 Z2 }0 j) g
: d& G1 ]! a* n I# L! h- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {# ~7 |8 ?- S1 p4 |) @8 r
- if (cache.containsKey(identifier)) {; D1 k9 E, x; T. n
- return cache.get(identifier);- J4 d! u6 h9 y* w
- } else {/ s9 Y$ l# |; f2 A$ h1 o
- final RenderType renderLayer = supplier.get();
5 T7 s5 h8 E: w. y$ L( [/ p0 X - cache.put(identifier, renderLayer);! M, g) P8 s9 o3 A; E2 v
- return renderLayer;9 B* p/ h8 O4 f2 M3 g, \; L
- }
: h+ j: y8 @# u: N, Y - }8 a- x6 J* N9 C; _ o7 {, j
- }
复制代码 |
|