|
|
6 k4 o5 S1 R* M0 B2 m/ A6 C
行,这个怎么样
- i7 O- e. F0 |) s- package com.xhg78999.mtrfac.render;
- N2 ~( O% H% J8 c+ [ - & p' ]7 E" k" ]/ X: n2 y
- import com.mojang.blaze3d.vertex.PoseStack;
& M M, p/ n5 S - import com.mojang.blaze3d.vertex.VertexConsumer;
( l: ?# b7 s3 x4 Q h7 B5 ?9 B - import net.minecraft.client.renderer.RenderType;
9 c: Z6 d' z. m - import net.minecraft.resources.ResourceLocation;9 }2 `7 U( a- U
- p& Q O j; E$ R3 ~+ h
- import java.util.*;
9 N9 W; ], V: I* W. I - 0 h& e: ~ T Z
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(/ [4 ]3 O* Z, y0 T, i
- 0 A( b' {$ m3 K, P6 t
- public class LineRender{8 W/ E0 m+ ^$ m
- private final PoseStack pose;
1 P( l4 E1 o" t% T+ m& ^. C - private final MultiBufferSource source;
$ a/ ^, e) E; C& L+ ?7 s; O - private static final Map<String, RenderType> CACHE_A = new HashMap<>();" L6 n: O; D4 e# }% q
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();4 b( T7 C1 k/ \
- . F8 x S2 u4 [1 P; }3 u
/ c$ \ h- G- ?8 W1 N/ w- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
6 F0 j/ }4 \8 { - if(x1 == x2 && y1 == y2 && z1 == z2){
: i9 Z6 ?- ^4 d: v! N0 ]4 a - return;$ c* h$ X: j3 L0 g5 F8 i
- }& e1 G- r" Q( ^( x
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){% l* j" b5 J% w; z
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
/ a( K g" \" D - }
! J5 E/ `1 x0 M" X2 u - pose.pushPose();2 b5 b7 U0 v/ q3 U9 Y
- final int newLight = convertLight(6);* R. @. q* a3 c8 b6 [: L. F
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));) _! h& o, k/ [: N: b( k
- final float lineHeightSmall = (y2 - y1);( Z Y- @7 Q8 T9 G; e
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);6 b- e, ?/ ]' T) H: _/ w7 \$ A
- pose.popPose();% [& l- r9 D- T
- }" ~! a3 d _4 b( i6 y j. R
! E+ r0 a) S! m; o9 l3 W d& F) ^! [* k- private RenderType getLayers(String texture, int light) {
3 S: w0 R2 e, f- U - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));( J- z+ e3 ]7 j% m. c/ `. n
- }3 g- `$ _8 w0 U1 s5 B
- - O" U2 `' `" [- ~) r4 H
- private RenderType getLightTexture(ResourceLocation texture) {$ b5 `4 K' a( Q* h* n* v
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);" _ s3 k1 c* R# c
- }
3 h1 }0 V* P# A5 P& j( V& d: t
! t& v( R. ]- P6 f* x- private RenderType getTexture(ResourceLocation texture) {" E% u; t4 W2 s3 y1 h) a7 H1 F1 U
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);0 }% R$ l3 ~; }) ~
- }/ L4 M5 Y) }3 @$ J
- 0 C9 J& S+ U& V0 Q, H% `, t
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {( B4 P# m# ?% A- k& S
- if (cache.containsKey(identifier)) {
5 R5 N; e9 h e( d - return cache.get(identifier);
( u' P |+ |% n1 L( T - } else {. l) Z. f( o7 R" m0 q* ~
- final RenderType renderLayer = supplier.get();
% R( q/ K) N" T4 l1 w* _ - cache.put(identifier, renderLayer);
/ z, W) @+ N6 m7 v - return renderLayer;
/ q; B+ J8 }% E0 D) y6 x - }
% ]9 m) o3 ?7 k/ @" M+ J/ ^5 _ - }. D ~1 S( N$ U4 ]4 `" F u/ K
- }
复制代码 |
|