|
|
) N( w5 b0 x$ A' C# [- J
行,这个怎么样# x7 s7 u: r1 K2 @6 \, S' o
- package com.xhg78999.mtrfac.render;! ]+ u/ C6 r, z' h* J6 M; |- e3 W
1 y! K1 x* e! S8 r- import com.mojang.blaze3d.vertex.PoseStack;" M$ X( D# L3 X: T0 G& D+ o
- import com.mojang.blaze3d.vertex.VertexConsumer;7 a- A: @9 n/ t$ E0 o
- import net.minecraft.client.renderer.RenderType;
$ y; E- F/ {5 |/ P: u' b j5 }; _ - import net.minecraft.resources.ResourceLocation;
( a0 _7 w- @# \9 N" M8 C! A
; B: C8 K4 Y; u6 Y8 k0 B- import java.util.*;
- J2 j; h/ d1 k
8 g+ l$ d% {7 [+ |; s1 t9 o! ?* V- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(: h$ M$ V- Z) M! {- M( H
- & E' R& e4 y/ L* m; C; t$ l0 y
- public class LineRender{% y7 B! [9 M. R4 U" ~8 }. m5 b
- private final PoseStack pose;
6 S$ l8 f x1 ^ - private final MultiBufferSource source;9 f1 H1 r) p3 \1 v8 ^# d& i& }
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
* M; s9 K* S' ?+ a - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();2 Y: z/ e: l* P( i1 v3 k& w. G* E
- A( ]: @' _4 [ Q; k
- 2 A w( { c. }8 R8 i
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
) n6 g7 N* b( G- e( d - if(x1 == x2 && y1 == y2 && z1 == z2){
4 h8 w9 l# r# a# v4 e8 J+ ` - return;8 ^" c9 M) H2 i2 ? R6 ~
- }# I& H6 J* ~& c a) w K+ g4 j
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
& j% V# y% N; M - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
) L7 j% `8 c7 Q9 c' g" F6 d - }
r7 y K7 y c0 Z2 U5 x - pose.pushPose();# b& ^- P4 r1 y, T/ ?2 e
- final int newLight = convertLight(6);
. ?: \) N7 m% t& F4 m$ u - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
; {$ L/ f+ F9 n' P8 ~8 l. S& B: K' D3 z8 t - final float lineHeightSmall = (y2 - y1);
8 g) Y# _: I U5 w, v4 g - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);; C" n3 k, d2 {" d, B8 e; k5 C4 o8 C* r
- pose.popPose();8 j, d! J4 O" {. Y3 B9 t
- }5 r) _6 U/ V* ]" l. }9 K6 q
- - I" g& }" Y( q% W- q
- private RenderType getLayers(String texture, int light) {7 o4 D+ C A3 Q# p- i# Y) t
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
+ v3 U, \) U0 {7 [4 L |$ ^ - }
8 f! W( H; W0 i - % F* p' ?1 x- Z$ ]4 w* E
- private RenderType getLightTexture(ResourceLocation texture) {
, D4 I! ]3 O# d: _; l6 |4 X" b - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
0 v) S3 D0 }5 H- x - }
) z1 b! ^) r; W) _; ` - ) U$ J5 p6 i" T8 Y/ r& Q/ |% W
- private RenderType getTexture(ResourceLocation texture) {( t! V( W) t* K3 E0 I: Z8 h
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);; G; q, f" Y/ \" R& F
- }. D( ]; ]+ u: e q0 C
- {) M }% z7 y9 _7 F( S- f
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
3 v! c: z# y" d; I - if (cache.containsKey(identifier)) {
# h% g' i; a' G, z+ Y! V - return cache.get(identifier);' l1 H- Y& k- |: S/ l, Q
- } else {
3 J3 j2 |2 t1 J5 ~ - final RenderType renderLayer = supplier.get();
" B# d" I1 K2 s3 t5 Y" R" x - cache.put(identifier, renderLayer);
7 u! s0 Y6 f+ [2 F0 p6 Z - return renderLayer;
2 n; v) f. L( U - }
5 s; \$ q) l5 c - }
) _3 d+ b7 r: C& a4 | - }
复制代码 |
|