|
|
6 f& O7 F+ X I7 D; B" {( W( `行,这个怎么样
3 M3 J" k ~8 ?. r% {- package com.xhg78999.mtrfac.render;* y" O- b) X4 f
( d* Z3 B1 t. N' o# V7 P* d: W/ S7 j- import com.mojang.blaze3d.vertex.PoseStack;! \7 D3 ]" t" h1 Z) |
- import com.mojang.blaze3d.vertex.VertexConsumer;
6 ^* G5 f3 ?: h3 K& D- g - import net.minecraft.client.renderer.RenderType;' }8 l* P' m9 Y, {- Z" H. y
- import net.minecraft.resources.ResourceLocation;
* X" q3 j+ O: ?0 m4 s, M5 d3 E9 u( t - & s) K( N; a) I U8 O e
- import java.util.*;
' C% w+ K1 _0 D% L5 L* g
) f' g1 [1 a3 S6 a- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
9 m' L' A- G6 Z8 c - 2 R/ h8 J5 i! @0 V( S
- public class LineRender{
* n+ g3 U% ^2 r! X2 F" y& j - private final PoseStack pose;
9 y7 ?- |2 o. v* } - private final MultiBufferSource source;
7 G# A, B# n9 t0 M' ^- a) ]0 ~) x - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
! c% U. N* G: u0 i" u" L - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
; S; ]6 h# I& o7 k9 ? - 7 O2 a" o% U2 Z% f& l9 n+ j3 v
( u) o" u0 J) N, ?& q- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){- o& }+ h8 L' p' e4 f* _1 Z3 I
- if(x1 == x2 && y1 == y2 && z1 == z2){6 Y6 r" V8 E0 S% i" x2 u
- return;
Q; A- ^) w" F0 ^ - } n4 e' O6 l& b3 o
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){! o$ C. a5 K0 m/ t; O' K# P5 |
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");+ c' _7 f: c3 R- F
- }6 u5 H- q6 D- _# M" p$ h o
- pose.pushPose();$ V, ]$ c4 l4 j9 t) m0 H& h
- final int newLight = convertLight(6);
9 j" k: _, G" P! |% p7 Z - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));5 h7 r8 F8 X! F2 f/ @
- final float lineHeightSmall = (y2 - y1);; p% `9 o0 x7 J# q0 I
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);: s, Q3 z% g) ?
- pose.popPose();
. s2 k7 j" `1 o* ^7 w7 G( s9 v - }
+ s h$ [6 R3 C! ? - , T, w% q q. H4 c, g6 a3 a6 t
- private RenderType getLayers(String texture, int light) {
8 r5 m8 v7 ?& M2 l# _# A/ B$ T - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));; G1 n; X9 _) [5 S2 T( v. D, I0 }
- }
3 U( i2 b. B/ U6 p5 Y* j# G
; t5 v. O% q% u- private RenderType getLightTexture(ResourceLocation texture) {
( a2 y& e& ~7 C; ` - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
# x ]1 Q# u& O4 t: D4 \4 v* ^, f - }
8 {: a, Q+ x. L& D
( a- l' C1 E& J. R$ I* o s- private RenderType getTexture(ResourceLocation texture) {2 R* y _( {) h/ n; j; P
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);& ^) q9 E3 k0 @$ p6 l0 I
- }
; c9 K3 r, q3 S R) ~
: _6 C3 {/ w+ [' K+ N, ~0 z- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {2 J- ?, u2 h, @+ R2 i0 n
- if (cache.containsKey(identifier)) { `/ s1 ^' e/ s
- return cache.get(identifier);
( v0 j. t; f$ V; S - } else {
8 `3 `" J& Y$ c. | - final RenderType renderLayer = supplier.get();
% h5 a) I" A* l - cache.put(identifier, renderLayer);
9 n# O9 [8 G, G9 @' f - return renderLayer;
3 Y6 o% @, ^! T" l7 f - }
) ]& ~: {* c B7 Q9 \) c$ q' W - }
8 v+ {( B h1 G+ ?$ s9 `- N, l" ?; j - }
复制代码 |
|