|
|
: \. | R% D/ j3 |) x* A
行,这个怎么样. ^. u L+ y" X8 G0 ^+ \* r7 ]/ r0 V
- package com.xhg78999.mtrfac.render;' r; g( v3 [) U* N8 ^
+ Y2 F- D+ z8 s4 k- import com.mojang.blaze3d.vertex.PoseStack;
! r1 \+ D# L* q$ v - import com.mojang.blaze3d.vertex.VertexConsumer;1 W6 J6 x% b: I. Y3 {! v# q
- import net.minecraft.client.renderer.RenderType;* p2 z% `, c# O
- import net.minecraft.resources.ResourceLocation;
5 U; N; j C' u- X( s) D7 T - ' b- }/ r/ @6 G
- import java.util.*;; a4 {( O# H4 U
- / f8 |2 e7 B1 g+ s7 U% m$ c& S
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
9 Z# T( |5 p) a9 F7 g0 S - & H9 }1 b# `- O r! ?5 V# r7 I) r) H
- public class LineRender{) Y% \* [- l/ P9 C) z9 T/ x
- private final PoseStack pose;
( W; t! o, }& Y" ~* c - private final MultiBufferSource source;
# g {( _; l' X7 C - private static final Map<String, RenderType> CACHE_A = new HashMap<>();# l" w& g8 P! @+ ]1 a7 W6 G6 F
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
: k4 X) W7 D( A# I" _; h2 t
# r" ?) j: `- _* z( Y
% x' V$ l- z. ?% J6 W/ ~- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
! |2 I/ j4 R! Q$ H - if(x1 == x2 && y1 == y2 && z1 == z2){
/ d/ J6 L8 p9 S0 e( g: P - return;
. ?+ R( o; V% J, A - }. D7 b( R3 ^6 E8 a2 Z) B. x% m
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
3 v* {" J: f7 `+ h& A5 T8 W6 t3 V - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");8 j, P# O" v6 L; z+ R
- }
9 J" `( m" I& J - pose.pushPose();
& b+ C1 ~& d4 M( t( {: s# c - final int newLight = convertLight(6);) ~8 ^4 N% R5 h3 U6 j
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));! x& P$ @5 p. R" M
- final float lineHeightSmall = (y2 - y1);" h7 M& f1 i ~- z* v
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
( u) q6 Y# I/ ^; U. k - pose.popPose();
. f9 i3 N$ i) T* x! z - }# L* j& Q9 V. C8 s. S
+ a n! @; @9 S& D1 d- private RenderType getLayers(String texture, int light) {1 @8 Y% Y* l' ] F
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));' x: E1 r% F. H2 k
- }( t' t% M2 c4 M8 N1 E
! f, B2 \7 i* V- private RenderType getLightTexture(ResourceLocation texture) {
) I0 g+ E' J) I6 `7 O) H - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);3 p" \0 i' c7 T8 U7 G+ p3 z$ s
- }
( p0 N' c* b# W1 t2 ?8 a
3 c& w( u# g8 R3 R- private RenderType getTexture(ResourceLocation texture) {) k8 v2 D# c# k) }! o8 R6 ], X5 P( _
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
5 ~5 ^' e6 K& `8 p2 r; s. n0 D2 R: f - }
" J' `6 v7 \* e. x- `. G" O - & \" X+ W: q5 V) E6 p8 W" r4 M
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
& J/ ^) i* T# W3 \7 l/ R" P - if (cache.containsKey(identifier)) {0 K9 o# \8 {* n
- return cache.get(identifier);
& r) \0 g! b# @, x; Z - } else {: ?6 V' E% r& d& a( A% Y( v' Y
- final RenderType renderLayer = supplier.get();! {& Q+ d/ u- o1 M
- cache.put(identifier, renderLayer);7 S: e% C$ Q1 G7 u5 l
- return renderLayer;
$ x. J& ~6 I% Z( Q( ~ - }
- ~" o9 i0 z7 o - }
/ U9 | ?" d2 S" I' O) j* j - }
复制代码 |
|