|
|
9 _1 k, t0 E$ X" ~6 R0 k1 C; I
行,这个怎么样
1 q6 Z# |% E+ C7 V. s- package com.xhg78999.mtrfac.render;
) l$ G/ t+ M8 X; A2 }
1 R) h7 d& r- a( @' I. \- import com.mojang.blaze3d.vertex.PoseStack;
; F& M7 @5 n( B1 M' F - import com.mojang.blaze3d.vertex.VertexConsumer;
* F3 Z$ M6 s+ F. j Y) q - import net.minecraft.client.renderer.RenderType;
4 z5 B6 ?; P1 [. a - import net.minecraft.resources.ResourceLocation;
+ f- ^: {% I% X9 R
6 r3 W/ T9 D; ?6 w! ^" x- import java.util.*;! ~& j3 r) I) v Z6 _2 K3 e
- " R& x9 P+ _" X! a1 w+ |; \$ ~7 v0 q
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :($ x ~$ y0 U0 V% Q% e9 O8 M q# B
- $ i. y$ W5 a; D$ C
- public class LineRender{0 B" n, q+ ]5 {/ s
- private final PoseStack pose;
+ f+ Z5 w( Y6 T' e# \ - private final MultiBufferSource source;
# q4 C$ o5 Z5 t5 w% U2 V9 r - private static final Map<String, RenderType> CACHE_A = new HashMap<>();4 I, j }; C9 z ^" x' J7 z" w* X
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();0 x3 T! @$ y: E4 d( u. z0 Z- {6 j
* g' P$ [5 T4 m9 }/ ?8 }' K8 n s$ J1 h
+ k& s, n6 N% _4 R3 M6 }- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){7 D5 ~8 A$ k0 [- D1 j2 H
- if(x1 == x2 && y1 == y2 && z1 == z2){
6 b/ c$ \/ Z0 }4 s x* h( I0 X - return;2 \+ k( F/ Z* o; j2 }2 y
- }
3 b4 y( V: |7 ~) Q6 M - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){4 }- m3 n) F3 ]
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");4 @6 A% l. I' _2 B+ C2 O
- }
0 v5 U. B5 T- M* L - pose.pushPose();. k4 v' \- W! [. h
- final int newLight = convertLight(6);( m: ]7 W& ^6 l6 O; c
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));1 q$ R) }7 q) q4 n' O$ K9 i
- final float lineHeightSmall = (y2 - y1);
4 m5 o6 V' Y- H - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);) q3 y1 a: P+ d. s: ?" D# W
- pose.popPose();
+ G7 W6 n( r9 Q6 O% ^ - }
4 Z+ r6 R/ c% G" q2 b. L2 d& k
6 H4 w7 p: F! E1 V/ ]- private RenderType getLayers(String texture, int light) {
# w6 n3 f$ T9 ]8 ~. V) ] - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
6 E6 n% ~1 O5 V3 m$ P% { - }: z! d# h& T* v; i
- & n A3 j. Q) T1 L* n% V1 `! n u
- private RenderType getLightTexture(ResourceLocation texture) {
, Z6 y9 S/ ]4 n - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
4 |' b1 V) u: w - }
' n, c' b8 U9 o/ g% @2 `1 @' e- o$ h
$ e/ Q8 r5 E; d9 d- private RenderType getTexture(ResourceLocation texture) {
* L ^" D n+ e7 w - return this.cache(texture, () -> entityCutout(texture), CACHE_B);; X v2 l2 [9 G; M8 A& A9 ?
- }* W+ ?' `" u& J
, i* R1 s8 Z$ t- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
3 v4 N# S( V- E6 T3 O- }) l) W* C - if (cache.containsKey(identifier)) {8 ]$ Q" z# V% g% h1 a9 W
- return cache.get(identifier);% n" N. L9 t2 L$ s& P" U1 p2 R
- } else {4 l* A- U% `4 D# W9 }# X
- final RenderType renderLayer = supplier.get();2 L0 ]3 n2 ?3 P1 g3 E- ]. E
- cache.put(identifier, renderLayer);" C* l/ {" C$ l. @
- return renderLayer;
! e3 N. t" b+ C* F+ m$ |3 l' J - }
0 C. Z1 U0 H( }8 x6 m: X - }; i5 {1 X/ u8 f! V4 F" E2 B
- }
复制代码 |
|