|
|
2 D5 A, b/ N, v: `4 e C5 D+ u
行,这个怎么样
7 ^) h0 I& F- i3 {$ G/ f- package com.xhg78999.mtrfac.render;5 E2 `# g$ w9 i; H* i
: k! |1 A( |' C5 ~- import com.mojang.blaze3d.vertex.PoseStack;
( k) z a9 T, C7 M - import com.mojang.blaze3d.vertex.VertexConsumer;6 i$ l) l5 ^$ m
- import net.minecraft.client.renderer.RenderType;8 H, B5 e% T& F. f- H6 A4 A5 C+ f* J
- import net.minecraft.resources.ResourceLocation;
6 @7 `. j, N& @3 t9 @4 }
* z6 K5 O5 |7 w" g! z! N- import java.util.*;
" k7 s1 o% D4 Z, U# i8 ~ - : G% _/ _7 A. r- n/ F; H
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
6 E1 l1 T- b* Z, a9 W# | - " O" A: ] E D4 j
- public class LineRender{" L" ?. U7 r! e4 {1 w
- private final PoseStack pose;
. F7 P, I b; z2 l- `+ j9 Q - private final MultiBufferSource source;# i8 n! k2 `& D R. X/ k
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
6 Z% I( n" A+ ~7 p- ? - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();" H) l0 p- p! X+ Z& U, n. A; l
( w- E% h, G; P" x: z! H
9 v* {. m" e7 v% K" U& f4 M- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){; p- l' H7 f5 Z/ w0 x9 g
- if(x1 == x2 && y1 == y2 && z1 == z2){$ S3 Z$ E. L9 R( [' B1 g0 g
- return;
! y' x! c1 l6 X' \5 s8 q - }: [) w. e; b1 ]/ L; P
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
- _; V3 Z5 e& E& [' ? - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
( x7 }8 L9 b( t$ `0 n( u - }
) g) U" U1 s3 `, } - pose.pushPose();
- b& I" a0 v4 E: _: K* c; o) @ - final int newLight = convertLight(6);
& @" G5 ^3 R# B4 z3 V - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
8 A. q% b$ i3 U& ^0 O( W. ^ - final float lineHeightSmall = (y2 - y1);' s- `! M$ {+ `
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);$ r$ G7 N1 Q! ~1 ~
- pose.popPose();
" h, U( G6 n; m; e- s6 c3 q - }! @3 m u! f" L- q. ]! X5 R
- % S$ c# h, }* o W+ p. m
- private RenderType getLayers(String texture, int light) {% V9 f+ c4 S, Z6 |
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));$ [. ~; C* o. c) t$ U1 j2 p0 k
- }
/ ~7 f, L% S0 J2 ?% ` - 2 _5 V" a% `4 o4 _% v( R
- private RenderType getLightTexture(ResourceLocation texture) {
3 K* g2 n5 h* _3 Q8 H) A( b+ I( k - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);& u( }5 Q1 Y" g* }# q7 k) V
- }
" N5 u/ o" d, h' D8 y: B, L9 @
# j8 v% h# h) o- e- private RenderType getTexture(ResourceLocation texture) {, W$ D% @' P2 G7 V, {
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
( l" d) C6 S1 q& L [ - }
/ y: _0 q; N# E( v p - ) c, D4 @$ I( [6 U
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {. {4 K/ v: e' F; Q6 |
- if (cache.containsKey(identifier)) {
" O9 p! S6 l0 q5 j - return cache.get(identifier);9 s. M. [6 U& l9 P% M0 Q
- } else {
/ J7 P3 f* e- k: {& i8 W# c5 M - final RenderType renderLayer = supplier.get();
+ f5 I/ k& E* V) C# P - cache.put(identifier, renderLayer);, Z5 t2 n3 x- G
- return renderLayer;- `, k1 K$ X1 M7 w. M' Z
- }
; Y/ U1 b9 s; \2 K/ z. e' @ - }( K( N/ j( y: V' C
- }
复制代码 |
|