|
|
; _8 |! A+ _/ Z: p0 t
行,这个怎么样
. \5 A( x* m5 o1 A4 u- package com.xhg78999.mtrfac.render;
s" v4 l5 W; c+ s
3 T, Q9 a2 O* @1 B) J9 l2 Q H) ~* x- import com.mojang.blaze3d.vertex.PoseStack;4 ?! M, g4 Q+ J2 p% O! y9 p
- import com.mojang.blaze3d.vertex.VertexConsumer;
' K, k8 Q2 p! @, J' Y* Q: q1 v - import net.minecraft.client.renderer.RenderType;
, Y) `+ r' b# A$ d3 @, l - import net.minecraft.resources.ResourceLocation;
6 `% L7 q l8 p f0 _7 k6 W l1 V- ` - + l' i8 b: S6 l- q1 [
- import java.util.*;/ l9 L! K" w1 M; W4 z3 A4 i
- * O. u3 B( Z% R! y5 W Q
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(* L! Y& x7 c9 U% ^' O
- 3 V9 b3 i" q c/ `
- public class LineRender{
) N3 G4 D6 p( g' i6 G/ A# _ - private final PoseStack pose;9 x2 F, D( Q2 a, K7 i( {
- private final MultiBufferSource source;
6 b3 R" G( s% A# g" R4 ^6 j5 J1 E - private static final Map<String, RenderType> CACHE_A = new HashMap<>();0 \2 y8 P/ H1 L4 C7 g; l
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();$ l/ h7 K2 s9 F6 ?( V% f1 U/ ^
) t$ H' w5 w1 P
_& ^. |% p F$ _: o- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){! n7 v, t2 D6 c8 T& Z ]8 C
- if(x1 == x2 && y1 == y2 && z1 == z2){ R# j- P% H2 @; B
- return;6 E8 z6 Q3 s9 z( K: a# `, }
- }
( t# ?! D& i' Q- T+ N$ ^% u2 _ - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){0 c" r9 `; x$ h8 p! b
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
9 R0 ~: H$ z' }% Y1 C" k$ m. R - }
; ]" Z+ U- F: U% R4 l2 d% a - pose.pushPose();/ x3 Q5 s2 U1 o; M
- final int newLight = convertLight(6);
0 G0 m" {1 M/ y% C# Z% } - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));9 d# `' B9 P5 J: a& H8 y# A
- final float lineHeightSmall = (y2 - y1);
- J8 S. J4 S, \! {1 t& ]$ p - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
- `+ m3 a, y8 v - pose.popPose();
7 J/ ]5 U9 o% U5 Y; w$ c6 q5 { - }
' D5 m2 s: N0 k" O: P9 `
$ Y7 p) S& J( G; E3 J$ N- private RenderType getLayers(String texture, int light) {& E7 d* [2 E# G8 U
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
E7 Z/ t% Q @8 G - }% l# G1 S# P8 c0 ~$ U, i+ l% L
! a( ^& p) w& w8 }6 o, K: k0 `- private RenderType getLightTexture(ResourceLocation texture) {' I$ n* n6 x- y* m
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
6 o5 K0 ?' O8 m& N' z4 \ - }: F/ ~! Y' l$ B y! o
- - d7 S3 w: y) s% ? J
- private RenderType getTexture(ResourceLocation texture) {7 z! j8 Q W: s l: ]
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);& T1 F3 J9 B3 A
- }+ Z6 ^6 Y) u6 J
- 8 d; w8 \) W/ Y: L4 a
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
. y# q Z. \5 F K. A/ H2 m) j - if (cache.containsKey(identifier)) {( ]$ [1 C4 |- b, K( A: Y6 j
- return cache.get(identifier);4 I& E- a3 W5 o4 [8 c" T% H# U
- } else {9 g5 p/ h# |% ^) B6 q7 S
- final RenderType renderLayer = supplier.get();
5 Y8 s" U- k0 \: E. w$ t: g - cache.put(identifier, renderLayer);6 F6 X C8 K* I4 v6 w
- return renderLayer;
; F, X0 f! e4 x - }4 `( h! @ \* J* d# Y; R1 b, Q8 G
- }; p5 z2 P* N2 [/ j2 M: ?
- }
复制代码 |
|