|
|
1 E8 [6 J' \' q- c% v# U
行,这个怎么样
8 P! G; w# A% M: D6 M* [. K8 O% z ~- package com.xhg78999.mtrfac.render;
7 c& r7 w: W/ n- E
8 G2 J& u# E, o) r+ F/ r- import com.mojang.blaze3d.vertex.PoseStack;
2 g5 g* k; w0 N9 I7 w% g ? - import com.mojang.blaze3d.vertex.VertexConsumer;
* h- w: D% u, M; Y - import net.minecraft.client.renderer.RenderType;
- I# K5 ^2 l( C: `% W# F2 W9 f - import net.minecraft.resources.ResourceLocation;
3 B/ t! E# F: K4 U" O - ) g0 n) A; A. V, U/ N$ f2 a. v
- import java.util.*;' E) _8 w- ^: d- {- f5 E
: Y! j) v0 x4 `- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(/ ~$ n t" ^ o( V! v8 @# v' P
- 3 w5 [, k' f& v' b% ^
- public class LineRender{
# m, v% M, r, m- s& W - private final PoseStack pose;; `, X9 [, h6 S! X
- private final MultiBufferSource source;* @2 h* t1 B1 @
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();6 g, ~" Q0 ~5 ]4 ]0 ? }5 Z
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();$ _' _/ s9 o2 F, f. }6 H7 }; q/ Y
9 s+ F" `9 y, s& Z* B
* Q% g4 _8 p& p- W9 t% \. [- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
" A6 `. X( N2 C z6 f, k7 ? - if(x1 == x2 && y1 == y2 && z1 == z2){5 h; o$ e0 O* |4 V- v( S
- return;
: _0 G8 J% F! s. p: o6 t/ E - }
4 y C) u, u# |4 J! t( R8 F& g - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
2 e* P; r5 {" }0 {0 v6 ]. t. L. U! t - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");9 l4 a1 m+ ` t+ R( \0 c
- }2 m: U8 g3 w- x
- pose.pushPose();
4 S3 y& ^6 l' [2 S - final int newLight = convertLight(6);3 d8 i" U. M/ |' i: l
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
. ?3 ^% W7 i# s5 D - final float lineHeightSmall = (y2 - y1);
& I% A8 v' N X! U. B/ f y/ @ - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);" H9 m5 J5 m# Q; z
- pose.popPose();
' E8 g# x$ w1 N9 L/ d0 U, `9 V - }4 ?# o$ {6 P8 X K; S% A
$ q) L% W$ T2 L, _+ |7 o- private RenderType getLayers(String texture, int light) {+ S4 q) ?/ p/ n6 N
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));2 z, u) @+ b7 R& b T1 G. A
- }
: a6 ]6 g0 a4 }$ S8 f
/ c( r+ A8 w: m m* W* o- private RenderType getLightTexture(ResourceLocation texture) {
: ]# R1 [/ n' F - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
/ h3 [$ u' h. u - }
3 t6 f! }& u) E8 z& T$ z4 O4 w
9 \" {$ a5 Y: Y- private RenderType getTexture(ResourceLocation texture) {2 S3 j2 t% G7 p1 i, y4 O2 j
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
/ T0 Z' y; r7 _: Z. S - }
8 Q/ H8 y. `1 [
8 P5 [ y, M/ C/ H* V- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
& P) n! e! H$ w2 a - if (cache.containsKey(identifier)) {
4 O' y! a, g, b: v* ?( O. { - return cache.get(identifier);
6 L, k4 T; m( h! u9 T/ P; b! h2 ~9 D - } else { e* d8 N, B/ G" m$ r( R, q9 X: i
- final RenderType renderLayer = supplier.get();! q0 [) Y4 ~7 w3 ~# R
- cache.put(identifier, renderLayer);* q. h y6 _( N X1 e1 a
- return renderLayer;+ |6 {- b/ {, l/ z6 }( f6 V1 a
- }. }" |$ V# n8 L& J H$ S
- }
$ C: X/ p% ]5 z+ c Y( J+ g1 @ Z - }
复制代码 |
|