|
|
; D$ v: P; P& t3 \
行,这个怎么样
7 ~2 a( U' |% |4 p3 y- package com.xhg78999.mtrfac.render;
* I# o' y' _1 X _1 N! S3 {) ~4 F
0 ~% G3 P' @4 D9 \$ f- import com.mojang.blaze3d.vertex.PoseStack;0 R0 E# I& P! r/ n0 m8 c1 W
- import com.mojang.blaze3d.vertex.VertexConsumer;
- S5 {; X$ s/ v7 @, O7 T( [ m - import net.minecraft.client.renderer.RenderType;
3 w( X3 Q2 K3 g. v2 W - import net.minecraft.resources.ResourceLocation;
: g. S' c" I( u1 E0 J - % K6 i$ ]2 Y7 C9 m2 z5 r6 K4 g
- import java.util.*;
: o0 v- m7 e# M8 Z5 H1 ]7 |
' e. K# L4 A9 L% u" @- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
* U' _% K. O l$ d; @8 k9 h( U- N - & _# N" {7 O0 H/ Y& z# q
- public class LineRender{. z; c. \+ `, Q# ^
- private final PoseStack pose;1 h- ]1 [/ p+ ~! S9 p2 e9 O
- private final MultiBufferSource source;
* ?5 A" x# ^6 J2 ~ - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
1 g7 Y! {( {( J; U- Z - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();8 T4 R7 c4 ^# U& M- h+ F* M
) \3 U' E. M {/ `
; H: J! D% Z8 _6 x# W- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
/ V' F3 U, i7 x" X# Z - if(x1 == x2 && y1 == y2 && z1 == z2){* m7 L8 \$ }# t0 V- A) `
- return;1 A, Q! r# p- D' V
- }
" t( n& G" f+ F1 d - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){. a/ ?. }6 c! J# u" g9 A- E
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
: e9 c {2 ^% N4 w, n* S. M - } V: A( q _ c. D4 K( t
- pose.pushPose();
; v6 X& N' ?% a; |( M- s - final int newLight = convertLight(6);3 ~5 O" L8 m Z9 b* Y; b
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));; t& l" _4 i3 Z/ ?
- final float lineHeightSmall = (y2 - y1);% I& C1 L H0 {9 q
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
0 h' E% ~& I8 m& r0 _( p& E - pose.popPose();. ]8 m/ }, `# V, O3 u8 e% o0 n/ b8 ]
- }' V P5 L0 q# ?
3 T( A' Q/ e0 S- private RenderType getLayers(String texture, int light) {; ^/ k2 d- u/ v& Z w8 k3 W7 T
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));8 y5 G- ~$ G# m; o2 v. k" X
- }$ G# l @, O. _! v
8 s: c. o/ e# d' q/ `$ o7 N, V- private RenderType getLightTexture(ResourceLocation texture) {" P# @* c, F ~' H5 ~- h. m. f5 P
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
: d y2 r$ v3 u* E$ p6 I, c% j6 L8 o - }
2 m) M6 b6 r9 b9 A ?
x5 G+ @3 u) \! X+ _, m- private RenderType getTexture(ResourceLocation texture) { H4 v3 }1 y0 y; u( a: k
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);& s4 p5 C7 k9 U! a
- }
3 i7 p; P& W9 O
6 B' Y# q. [2 j) v' R+ p- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) { b" }% l( ~& s
- if (cache.containsKey(identifier)) {
: B6 t9 C4 G9 I6 ]2 M' j! m9 H - return cache.get(identifier);
+ q" R7 W6 ?" d! a: j- j) s - } else {
; w9 Z7 s: I& u6 e4 d1 H% p2 X - final RenderType renderLayer = supplier.get();# {$ e; x& |3 @2 N9 x9 ^
- cache.put(identifier, renderLayer);9 F, W8 Y5 D$ r3 D# x$ I3 S
- return renderLayer;! C/ p- O: p) v5 P2 ]8 N; K
- }
0 p& ]5 N- O. p - }# {3 C; Z3 e \- w7 O# H: z
- }
复制代码 |
|