|
|
$ @3 k5 N3 c; ?+ w0 {, _
行,这个怎么样5 `* S. I4 l+ K/ o- P& A/ n
- package com.xhg78999.mtrfac.render;: M- ?6 _6 U2 h* z9 n$ {3 N
- & Q% Y- e' ~1 f. q$ D
- import com.mojang.blaze3d.vertex.PoseStack;# S, f) C6 I6 [7 }
- import com.mojang.blaze3d.vertex.VertexConsumer;0 B4 e( Z3 f% f- Z* i% }/ V+ x
- import net.minecraft.client.renderer.RenderType;
" [" B( ?! }, E9 q# D5 c4 e: B+ F$ a2 J4 p - import net.minecraft.resources.ResourceLocation;
: A9 v! z% Y1 c! b - % t# Y- d! d! N* ]9 r
- import java.util.*;! _& ~# {; K. |' v. W
- 6 T: k$ Z8 K4 t
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(; [, n5 H4 L* T$ N% l# D6 b% d( `
- * {/ o& V; u, _: f0 g! ^9 H+ h" r
- public class LineRender{) p# ]0 Y* H$ q
- private final PoseStack pose;
' u" L/ v9 A4 ? - private final MultiBufferSource source;
7 _! f2 B- l7 w! }3 e/ W- w - private static final Map<String, RenderType> CACHE_A = new HashMap<>();8 I, g4 _7 o, C3 y/ T8 S3 L) s1 j
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
/ S1 I6 l8 m- h F. S) Y# o - # l5 Q- ]8 j2 d4 r, E* Z
- * j# y* H* w5 E5 r
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){5 E+ k, @! Y. o* [9 c7 {
- if(x1 == x2 && y1 == y2 && z1 == z2){* |' o: y$ `+ d5 O' h9 r
- return;
+ a, K7 C1 j, Y- k5 _' I - }( }! |; F& X$ w' Y5 K
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){+ x2 P; _8 ^! I; N
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)"); J- E: B* N& @2 Y
- }4 Z" W! r) f9 Z& S: ?# d2 i8 Z4 K
- pose.pushPose();+ ~" d- a# c2 k& z, q" |$ O
- final int newLight = convertLight(6);- ~0 [- o; V# Q
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
" B& c) X: v/ r+ O- j3 C - final float lineHeightSmall = (y2 - y1);! Y z2 N- R. D2 J e
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
8 }% _. N% J+ T4 n2 x - pose.popPose();* C" T8 L. \' O1 r6 p, a' C/ P( T6 t
- }
i) e1 U! ~8 G$ f0 V
; j. S& X8 q3 y, {4 ]( t3 U- private RenderType getLayers(String texture, int light) {
/ W, {" t$ ?* g) h- ? - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
2 e8 z1 j+ r1 M0 c: @8 O1 a( v - }: b/ p0 T- b) Y) M' _- ` g
- t7 C2 G: y. s: n* x u- private RenderType getLightTexture(ResourceLocation texture) {
/ a- K* F* W8 M - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
3 [' C k' M, E, U2 w - }
5 `, R5 p% ~; E# s- E - 8 F+ b2 k0 K |/ f8 ?
- private RenderType getTexture(ResourceLocation texture) {
* U% b+ e f$ o+ S; g - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
) `5 C& O0 b) M6 O$ _2 {$ m - }
: i, \2 d0 Q+ _( n* P
( h# b8 T6 U- {- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {/ `' \% h3 L- j! _ Q
- if (cache.containsKey(identifier)) {
; A2 U: J" U9 V5 f - return cache.get(identifier);, Y; f, O. ? [" B: Y( X) ~
- } else {
, R$ z! g# ~2 b- n/ Y1 B1 l - final RenderType renderLayer = supplier.get();
8 U- r5 }9 p' n( U! `! X# u8 |, p - cache.put(identifier, renderLayer);
" v& j6 |' N5 l - return renderLayer;
( ~9 G1 }7 |* g5 @ D - }& y& W7 Y2 E2 ?* D
- }: a; T3 Y* B! H
- }
复制代码 |
|