|
|
$ t* x; O1 M: }9 p行,这个怎么样
I0 r! E5 \7 e% s7 X- package com.xhg78999.mtrfac.render;$ K' G2 h. a) g7 [ N# [
5 \5 \5 y/ Z; E% N) |- import com.mojang.blaze3d.vertex.PoseStack;
z; l& A. c+ N6 s- }* O - import com.mojang.blaze3d.vertex.VertexConsumer;
, H' N, g- H9 }+ L, }& n - import net.minecraft.client.renderer.RenderType;
% h( S: [* {, a$ A6 ?+ Q7 V - import net.minecraft.resources.ResourceLocation;9 j" s7 ~) L- X3 e, @
. \& [- k1 o5 S- b" m5 i7 m2 @- D9 m- import java.util.*;
2 t, `/ [* s8 u4 l% K. x
. @" e) J# R6 o0 |# r0 }; w- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(- G1 F; [9 r! k' ^: b, f
- - h0 F# v5 _5 v& F; {( ~9 \
- public class LineRender{
" j! m0 C2 x2 a4 D4 n6 y0 ~3 n - private final PoseStack pose;
" t- Y7 F: I0 [0 h/ |2 m# I - private final MultiBufferSource source;8 s- `& ^, r: w. l( R) R8 w( M
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();& Y% p5 C8 D! ?/ B3 D
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
8 \: f2 t2 p+ }) }/ ]/ h+ h" Z - ( d" u( ~- C1 f. P. e% @& K1 R8 \3 s
- / A4 ^ A8 G8 x
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){5 O& b3 ~8 W7 ^% b
- if(x1 == x2 && y1 == y2 && z1 == z2){
" y: [8 H9 U8 E - return;
/ N, P/ s3 Q0 Z - }
2 @- \, p) F+ i - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
& h7 Q$ _. l; Z* l - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");/ |7 U( A! l3 T$ @( _3 J( u
- }6 l$ q, e( n! n% v! v( A
- pose.pushPose();$ B7 V1 |, q2 w
- final int newLight = convertLight(6);
( C5 P% w2 d* T% ? - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
, a- M, k. Q" D' G& Z3 @ - final float lineHeightSmall = (y2 - y1);- D; p/ S. F, Y; e! @: y
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
& }8 U7 s8 X, {$ n8 Y - pose.popPose();
3 u, h% c% W2 a( x - }
; t5 E& }, R3 ?: [! X5 g/ a - ; P0 x4 |7 r; d3 W7 I! m
- private RenderType getLayers(String texture, int light) {
( L8 S, l& J, S1 y+ t. w - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));6 |* q; h5 f; L- F# B1 e
- }: @+ t; f% F3 M, \, h O3 T
- + S) G0 g, I9 ?7 n
- private RenderType getLightTexture(ResourceLocation texture) {/ @5 i( ~$ N' S& _& G; `, V, d9 `
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);! f, P% E, E% l3 q) j( ~; J
- }
+ @) d* w |9 E3 Y( l/ ~0 W
# M C; B6 k, z" ]& k- u, Y; n- private RenderType getTexture(ResourceLocation texture) {
1 Q* z( u4 ~! ]$ L4 v m( z3 _ - return this.cache(texture, () -> entityCutout(texture), CACHE_B);3 g( S* h ?$ ^( }
- }1 r( u2 Q, D* s3 \. o+ g- M& I r% q
- ) R: [. x- x, D6 r7 |
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {4 _6 \# m: G' m7 G6 k
- if (cache.containsKey(identifier)) {( L) n3 O: F# T' _* y$ ~7 k: V; C; N
- return cache.get(identifier);7 [. F1 k! O% S' I# O
- } else {& M2 m: P& q7 }! c7 k8 Q5 P
- final RenderType renderLayer = supplier.get();" |- D8 ~' N" N3 A" k' x3 }* u
- cache.put(identifier, renderLayer);& t% ^2 h2 ~+ z, }5 c
- return renderLayer;( `: S2 P9 P- _1 W( m; O7 N/ O+ U
- }5 a" ^' g8 A/ m/ p8 G' z% |* Y
- }$ E& [2 M: I/ L5 V
- }
复制代码 |
|