|
|
3 T( Q) z! j. A. z- j行,这个怎么样
9 U2 h O3 s, M( D: k- package com.xhg78999.mtrfac.render;8 B u3 y7 b" O) s
/ V0 e$ `+ g I! m- import com.mojang.blaze3d.vertex.PoseStack;- a. Y" v. I/ J8 K1 h2 m
- import com.mojang.blaze3d.vertex.VertexConsumer;
, Z8 z; ]2 }; b+ @' b- _ - import net.minecraft.client.renderer.RenderType;
3 n/ s3 c o; R" G% W+ ] - import net.minecraft.resources.ResourceLocation;; {8 y, l# q- C( u0 N* b
- + E# B! f# G: H! Z8 V6 u
- import java.util.*;0 y6 J/ w+ U6 c, v: D$ V
1 A1 K3 l' s& p/ n5 K) k3 m- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(6 m; c' i% C( \( Y
- ( [/ F. z! I6 h- z% a. M4 W
- public class LineRender{
6 H" A' C' f) L- P - private final PoseStack pose;
7 N' J5 P+ Y8 g8 d) x* h1 j% s. I - private final MultiBufferSource source;
- V) M5 Z9 }/ Z1 B0 L - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
# Q* e, T3 m- j5 |) {5 K0 | - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();9 G* }' t0 F" g* I' E
3 D7 ~$ D" v' w( L
8 w# g. R+ G$ L; N% K! I- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
# Q/ J( I6 s4 N' m0 D+ J2 l' s" Z - if(x1 == x2 && y1 == y2 && z1 == z2){
( q, o7 i, W. N. U - return;1 [/ f# N2 [' v9 f" o
- }3 j" {- ~# V( X' Z5 B
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
; H. c6 M6 \) y- w! i - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");5 C( i5 a% U1 B' r) X' X
- }0 N% W- u9 W. Q, T/ J" w- b) e; U
- pose.pushPose();
: Q* ?2 v" R0 N4 p4 e, y: J6 \ - final int newLight = convertLight(6);: w+ z0 C9 I6 v. e3 K' L
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
" y3 Z% T0 C2 @* _4 T. c$ R2 S; O; W - final float lineHeightSmall = (y2 - y1); m3 S) a$ \5 r% T
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);5 m% i# ^9 F7 Q1 p+ ]* h8 I$ O: x- e
- pose.popPose();: P/ N( t4 [& t7 b
- }
; p: M; X8 ~# R - , \# z' J% D9 X& J( u. h: C
- private RenderType getLayers(String texture, int light) {
+ n6 F2 Y3 h) V - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
3 \, N( A" m# g6 q - }4 r2 |+ w( V8 I' _3 f2 f# b" n2 Z; o9 q
- " v% i8 ~* C: K- Z0 a
- private RenderType getLightTexture(ResourceLocation texture) {
( p5 J2 ~2 Z+ G6 U" f - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);% l! N9 i+ S( x3 f, ?
- }7 t0 W1 I% V0 H6 E
- 9 ]+ B7 T4 B3 H9 E% Y
- private RenderType getTexture(ResourceLocation texture) {
2 ~9 k- r$ ~: U/ Q& f' f - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
7 A5 \& n: n( s+ z! F - }9 k6 K8 z- h X- {: L( R
4 ? g3 \. w" V3 I0 J5 R! C6 L. {. a- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {/ h" p& W- }. l5 D! T6 A* X2 }$ x
- if (cache.containsKey(identifier)) {
* i( b/ N7 M) ^' ]. {3 _ - return cache.get(identifier);
7 S) r0 l' k6 B) C - } else {
- E9 ^( B b4 ?2 T2 i4 m, K3 \7 C - final RenderType renderLayer = supplier.get();
0 ~" y- i3 w( m+ t2 ?, r; ]' \ - cache.put(identifier, renderLayer);, C; d3 S. b5 ^3 M$ K
- return renderLayer;. S& h0 D: k: d4 Q k! C
- }1 @/ `6 B2 s. x
- }
5 j9 ]+ R; {& M. _- {% l - }
复制代码 |
|