|
|
* E2 J2 E6 d+ z
行,这个怎么样% t. J5 R1 _. a8 j1 {7 ?4 o$ i
- package com.xhg78999.mtrfac.render;
; h: u& G8 n* `% J0 x
, K0 k- M* a& C% A0 x) O. v( F- import com.mojang.blaze3d.vertex.PoseStack;1 b1 Z6 `, b. Y5 p+ h
- import com.mojang.blaze3d.vertex.VertexConsumer;. I7 i1 l" b- x! s, u) a5 c
- import net.minecraft.client.renderer.RenderType;
- Y. D8 g3 v+ L9 A: d - import net.minecraft.resources.ResourceLocation;
' z8 z8 n7 a1 ]/ m8 |; \9 {
0 I2 L7 l- Q; @- import java.util.*;0 q3 f: V [% C) d( G/ R
- ! E4 J& U' C, Q6 f7 F7 a3 K3 ?# j
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(7 d8 c8 f s8 c: W& Z- @& @6 s
- 3 s$ h/ S/ V6 D- z9 p B4 O f
- public class LineRender{
' F! Y& ?/ t! O* P1 d - private final PoseStack pose;
: q" m Y( m c! @ - private final MultiBufferSource source;0 q+ B$ ~/ \- A0 A' P" G
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
# r/ O. `) b, X, g - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();: [ N5 F0 x! Y, y6 H/ {2 C& R
- 3 |: q6 p" e! R" Z3 w% m) P0 A
- , q$ G1 t9 p' f* t; A. Z5 T K8 X
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
^ J3 ~) o5 d: v: }8 m - if(x1 == x2 && y1 == y2 && z1 == z2){3 D5 R0 U7 X% i% u# r1 V0 z
- return;2 ~$ \: V9 e$ b) l3 `
- }
7 L" k/ C, x* ~8 | - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){, N, P9 P# t+ o4 d; q
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
, x' Y: n+ l8 @; f - }
1 G$ }: H o$ }- Z" d) r- F - pose.pushPose();
5 ~# U! j7 L) W0 Y - final int newLight = convertLight(6);
+ b, V& `5 [6 E" m- z - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
$ k! z5 J- T$ G( L+ w - final float lineHeightSmall = (y2 - y1);
/ ~: w) y3 I- l% I& f) p - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
* z5 p9 w9 R! j; I' T. L% u - pose.popPose();
4 ~) ~2 { {2 Q, S( t - }3 U; c4 f1 u8 @2 {
* j9 ]. E+ V" g" n% s- private RenderType getLayers(String texture, int light) {* n8 |* o6 m- t3 U& o
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
( n. G/ k, L- x, U - }
6 A. L1 S; `: P - 0 Y; d% w# c& l0 j) |( U+ p
- private RenderType getLightTexture(ResourceLocation texture) {5 H; o" G2 X* E! r q
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);" E3 K9 R! l5 h* ^6 i) i
- }) w5 |5 _) r9 h* N. R+ s
- . Y0 \; Y0 d; f, a3 v
- private RenderType getTexture(ResourceLocation texture) {
1 k4 S$ E; J' q, @& k- v+ L9 H - return this.cache(texture, () -> entityCutout(texture), CACHE_B);9 R4 z4 [/ g/ t0 f4 e
- }
) c4 n3 U: k9 H9 c# N - 6 S2 r: A3 ]# I* ?3 z; S0 f1 z
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
5 h! O- I0 {( b) H! \3 `9 `4 D ] - if (cache.containsKey(identifier)) {
$ c v. }$ ]! U! T! h4 |3 K+ H Z - return cache.get(identifier);. r7 `! s) }0 i# p+ I
- } else {
- L+ q" R! F& Z n: `* z9 x7 o: C - final RenderType renderLayer = supplier.get();
+ M E1 {) b$ \ - cache.put(identifier, renderLayer);) @8 m. w7 \1 c9 }; |5 V% m8 T
- return renderLayer;
( K: w- c( X. P, ]( W; k - }
% q; y6 `. m( ]: D b - }$ o: g; @8 h3 ?0 S: I, ~% ~
- }
复制代码 |
|