|
|
& b& Z' Y/ [- l* Z- H1 X行,这个怎么样6 n) \# a: I! M) \
- package com.xhg78999.mtrfac.render;4 c }9 x- M9 J, C3 _: X
) i# l: @4 C( x- import com.mojang.blaze3d.vertex.PoseStack;7 m* @- t. w. C4 p. j7 @0 d4 U9 M
- import com.mojang.blaze3d.vertex.VertexConsumer;
( D2 `. M+ k% r* x* z. z - import net.minecraft.client.renderer.RenderType;
2 O' N, H. o- W7 P# x5 E* Y - import net.minecraft.resources.ResourceLocation;
: H3 |$ t1 d1 b* u/ F - : z1 O! @$ Y9 R9 [3 I- A
- import java.util.*;
- @6 N# G. k) a4 C& N - 0 z u2 {+ ?5 L. j9 B7 S
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
( q* v9 D9 ~ z/ W. A - , j7 E% t3 W' }% u" z% O$ N5 y# A
- public class LineRender{0 @, A8 T2 \ _8 m' Z q
- private final PoseStack pose;& E9 B' ~7 A+ g: {; C7 R- H+ J7 G4 X% T3 f
- private final MultiBufferSource source;/ M" L5 @. z) q3 ^
- private static final Map<String, RenderType> CACHE_A = new HashMap<>(); u& P2 O9 U% @5 k% v3 x
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
+ U8 K. U: D: J9 m
/ H* L- ?4 a$ }% D1 |# u
" i J& J% t. @( T& L! C! ^- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
8 \: \( F5 }1 l% A' T/ z - if(x1 == x2 && y1 == y2 && z1 == z2){" a0 \2 r) C( n# ^* u
- return;5 `4 V& m6 C/ l! l& F2 k$ i
- }
7 M/ g# b; {- `! _# @: g - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){4 L" g6 r+ w3 v. f
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
) I, a5 T$ j; _3 O; L$ _* j - }
1 U. v! k. z9 W7 a9 Z/ Q - pose.pushPose();5 Q& x( o# Q' z! S4 C+ m+ h. g: x7 o+ Q
- final int newLight = convertLight(6);
" P& v; _. }% n8 \$ w5 d I - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));! x# F& J9 B& c# u" i, x* }
- final float lineHeightSmall = (y2 - y1);
1 N3 c# t. y2 U/ w8 Z3 L# _% |& m+ t& ~ - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
5 ^6 O: V- L( |9 ]! d5 P. M: U, q - pose.popPose();% v _2 [& F% J, n
- }, G( @' p$ q0 D9 g
/ ~2 M7 e: E, F; _# z' Q- private RenderType getLayers(String texture, int light) {/ o$ e1 @$ P a+ t \! g, ^
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));9 p& p* U# ]. |6 C q
- }
6 }# Q, j# j; { p+ Y
/ s$ H Z" t; I0 D4 h ], a" z- private RenderType getLightTexture(ResourceLocation texture) {9 e3 W* \! }7 s! O
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
" Q9 ^4 ]9 r9 z8 Q$ o8 V4 k$ y - }3 N( I1 j; x2 F. H' x
- + b5 q9 u2 l' r& ^4 N
- private RenderType getTexture(ResourceLocation texture) {
6 d, f" ~, T& Z. {" V% F4 _ - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
1 G) {) f% O, _ - } r! L x+ E0 q ?& B' G( D
- ) b+ T- G% p7 a- G+ p
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {$ L# m. K- o5 j$ K: l8 d
- if (cache.containsKey(identifier)) {
# H, N( s; z5 F5 ~7 g) u2 V - return cache.get(identifier);* b( {- w- b( W; J3 _1 U
- } else {0 {% N4 _5 I, _) L0 @
- final RenderType renderLayer = supplier.get();- i0 O% A5 W6 A- J$ W. `, e# w) c
- cache.put(identifier, renderLayer);" V9 T$ J- h: I) V U3 N5 G: N- T! _
- return renderLayer;
' o1 F. U! h* m5 K - }' u8 {; ~0 ]% D
- }
0 y$ {. }3 C! Z3 Z - }
复制代码 |
|