|
|
4 y- [2 b% u: P9 W
行,这个怎么样
$ n4 s, y4 z( Y7 H8 g- package com.xhg78999.mtrfac.render;
# v6 b; e" c( f, p5 b3 b3 S
! D0 Q6 U& ^; J b7 g4 A0 r6 Q# m& X- import com.mojang.blaze3d.vertex.PoseStack;2 ~5 V5 H: M9 I* q4 W9 e1 _
- import com.mojang.blaze3d.vertex.VertexConsumer;) A6 E. U8 |) r3 E
- import net.minecraft.client.renderer.RenderType;) v: d) M: W5 n3 c) C0 O
- import net.minecraft.resources.ResourceLocation;. E' k' }, G" N
- " \$ Q3 a; \! R1 X1 u
- import java.util.*;# R- a) H3 Z, `. ]$ i4 X r
- 1 t6 r$ a, B- a
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
! N& h7 f- C/ Y/ h - , U* b- s+ C4 U, i4 d. E
- public class LineRender{, D! Z! U7 \" J/ Z2 I
- private final PoseStack pose;
0 Q1 U- _; I0 c9 u: ?- f" o' Z4 T& Z - private final MultiBufferSource source;0 q3 q6 O) m+ ~/ K( A8 X
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
$ x" s) V: H0 \ - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
1 F' [+ u1 ]( _4 D t, g - ' x% g; j6 Z7 Q7 Y3 r. U5 b
$ M+ c* ]2 ~& ?6 i- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){+ }0 [' |5 J, I4 B
- if(x1 == x2 && y1 == y2 && z1 == z2){
a& |; s5 f$ q; w - return;5 C. d8 D5 v, r' K6 r F( `
- }
# L% x/ @2 e' M' S |6 a. v - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
* ?& V0 P4 U1 ?% Y; [ - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");9 b$ d$ K4 I+ L8 {: x( X
- }
* a/ q: u( J& Z! l8 V* }$ E - pose.pushPose();
7 }6 g W& d$ t( t; R3 i2 K - final int newLight = convertLight(6);# k& V5 j q+ P1 u, C5 A" m; i& q1 y
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));8 ?4 i6 V% r r Q/ z
- final float lineHeightSmall = (y2 - y1);
, Z' g% [/ }* a( L- V* I - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
/ T4 t; f6 v: x7 Y& |! } - pose.popPose();- M9 P% y' m7 Z7 y4 d% P: {. k! u
- }
$ y1 Y! w5 r" u - 8 w7 G6 Z2 C) I. A+ M
- private RenderType getLayers(String texture, int light) {
9 n' _# M2 d" @0 I0 ~9 v4 h - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
2 x, I6 ]* j; Z, X - }
+ \4 f9 t3 {$ j
% W0 D+ h9 u* ?# Y- private RenderType getLightTexture(ResourceLocation texture) {- Q3 z% W' J u
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);9 [' Z4 _ U6 L: r5 Y1 k" @
- }
6 M# ]# `7 ]. C: ^1 ?6 ]: W* x
8 f) C2 I! A$ l0 ^- private RenderType getTexture(ResourceLocation texture) {2 U+ j# `$ `1 |
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
6 W( ?$ r/ V6 I8 d2 X' p. S/ n - }
5 }; u' R$ l; B: g- F S, k, d
" Y' ^: @1 X2 f( v4 T# ]2 p- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
7 J7 M8 e1 J8 d+ a: B! { N - if (cache.containsKey(identifier)) {7 V4 z5 e. O1 b: S. D6 S
- return cache.get(identifier);
/ X# u( F* h) Q2 P& ^: x - } else {
% m, Q4 K9 p8 ? - final RenderType renderLayer = supplier.get();
! f+ M$ Q) g4 R% q o- p - cache.put(identifier, renderLayer);$ e# k* A3 k- e7 |' M/ X* `
- return renderLayer;
) V3 Q8 P( J( p6 N! X$ O - }
0 f4 R" p: `9 d* U3 u3 w5 N - }" _# \2 O I. C' N9 z/ p
- }
复制代码 |
|