|
|
7 E! P4 o9 K8 o( M
行,这个怎么样' N* r \3 B/ Y- d
- package com.xhg78999.mtrfac.render;: b, u# T% L! v* m8 A+ u
' {" \# c' ]# U4 W$ C7 N3 }- import com.mojang.blaze3d.vertex.PoseStack;
2 B0 ]& E- g* a' S" I1 z# E( J - import com.mojang.blaze3d.vertex.VertexConsumer;4 `8 k& x' {1 D) N8 h
- import net.minecraft.client.renderer.RenderType;
; J- M: y6 ~; E. W% N7 |1 v, u) O - import net.minecraft.resources.ResourceLocation;( {% b$ V) B2 I- T
9 U$ O- @& t% I# W" L- import java.util.*;
$ O/ z* m* K) E$ c- f# e6 b- m9 J# v6 l! t
6 \8 J: G2 y5 x- C9 O% P- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
" ?2 q& a- z/ H# l. y" `) D- m
1 Q" ]+ M+ H; {- public class LineRender{2 Y0 B0 U0 e( L- \
- private final PoseStack pose;
) S) W" y/ a3 g1 Y6 A' B2 w - private final MultiBufferSource source;
% {" r E1 `6 u4 P f - private static final Map<String, RenderType> CACHE_A = new HashMap<>();. {' f- W" h2 R3 d( I
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
+ {1 _* L. U3 g b0 U( r% y9 o& ^6 o - 0 k' d& Z' n' T$ ^( i5 O$ q) |
' {4 m$ H+ r# ]- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){/ z1 ?, {0 ?# D4 b5 W: V
- if(x1 == x2 && y1 == y2 && z1 == z2){
, {% U% P7 e2 p6 f' m, ?8 ~ - return;
# O, ]4 W5 c+ j# q1 v - }8 W2 M# \0 k4 B v% f" D
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){& P8 a9 o( ]: U
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
3 v1 Z( ]" Z% q, [$ u8 ? - }; v* c3 N+ E5 j5 ^
- pose.pushPose();( k% q+ ^. R/ z4 r' q7 A* T. a
- final int newLight = convertLight(6);
% ]( `' y. J- S" } h$ ^) Y - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
4 H6 n, F9 x8 V+ A - final float lineHeightSmall = (y2 - y1);, S; r) E0 H/ o" _ T
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);2 C l4 m! t9 X$ S7 f7 L% ?+ c
- pose.popPose();
$ N% G/ g1 \7 D' p - }& s1 a2 d+ k+ G$ h$ O3 }, w
- 9 l T: z8 d& d- _+ t
- private RenderType getLayers(String texture, int light) {4 l& O% j7 a7 t% }
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));5 x: g: V2 D( Y8 C3 _# M
- }
, t7 r& x! S) Z8 A
1 \6 A1 E: [( |& t4 O- private RenderType getLightTexture(ResourceLocation texture) {$ l" I( ]' K/ ^/ l$ R7 L
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
/ A+ B/ G7 E$ w - }, {/ z1 \; v- M4 D
, }9 S" b7 |0 ^! h- Z, l1 B# W2 A- private RenderType getTexture(ResourceLocation texture) {
$ A+ {# R3 s9 X1 d - return this.cache(texture, () -> entityCutout(texture), CACHE_B);" S# r" t" Y9 f& U+ L m# L3 ^/ z
- }& [0 Z" V0 y$ H- H4 Z3 _
- L$ v8 j1 F3 }, T, j& p! P- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {( a) v( M9 }& m. O4 i9 M4 A
- if (cache.containsKey(identifier)) {8 _1 T) z# D# K$ G- H" V+ S
- return cache.get(identifier);
: Y/ X! t, c1 q& ] - } else {
/ j* I: g3 i5 t: B2 t; I# M: L - final RenderType renderLayer = supplier.get();6 p5 K3 {3 V, e1 s- d
- cache.put(identifier, renderLayer);6 o1 S, e( B, s& t- B9 O
- return renderLayer;9 L$ G5 Q2 y+ s6 j3 I6 f+ r" r; B2 x
- }4 ]' x7 W; a% q0 {& l
- }1 u+ |, P2 x r' e2 M
- }
复制代码 |
|