|
|
I1 ?* B) U/ I' r行,这个怎么样6 O; a' g" T7 V$ P: o, _ f7 R
- package com.xhg78999.mtrfac.render;% H- J% c; K! \" P( _. \- a% Y* ~3 v
- 2 [. L: T8 W4 O( T
- import com.mojang.blaze3d.vertex.PoseStack;, A! M& B; z0 |( p3 X
- import com.mojang.blaze3d.vertex.VertexConsumer;- @$ [% Z/ E4 o2 O/ G5 P
- import net.minecraft.client.renderer.RenderType;
5 C9 E, m0 ~( ]/ T5 [' b) z - import net.minecraft.resources.ResourceLocation;' S% F6 R$ y7 X, a- @
& f8 y1 I! F' }8 Q' W- import java.util.*;
3 ]' K5 M, I0 p6 T/ [ - * b: x- l7 G, |* j) P
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
$ D1 f6 f+ a0 _ - [0 X8 a; E5 j' { y
- public class LineRender{
0 T7 ~" e5 H# b' [1 A5 Q' O& @7 b - private final PoseStack pose;$ n$ u8 [- |8 d( ~ Z
- private final MultiBufferSource source;
^3 K5 L# p7 m7 k9 C - private static final Map<String, RenderType> CACHE_A = new HashMap<>();; O. }. x3 b4 a
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();* v" ]$ m( Q& E. ^+ r
- : L- D6 u0 I2 w9 i7 s' i
- 6 I) n' y! l$ A9 k4 F9 b
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
( \! B7 T- h4 d1 { - if(x1 == x2 && y1 == y2 && z1 == z2){+ H; m% ]( c$ j& B
- return;* h* ^9 f. e5 R7 M! f
- }
, u1 Z4 r8 A9 k4 T+ M2 l - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
L: u: t( T, U9 ]( O* b2 T - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
( d! [# p8 ~1 L1 o - }
8 j3 t+ e! L9 Y" U - pose.pushPose();
8 L4 f! b/ q5 f6 B2 f% e - final int newLight = convertLight(6);: Q+ q8 ^5 F7 b- U" H7 j" q
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));* ?7 ]7 |/ V2 o- ?) t: ~, W
- final float lineHeightSmall = (y2 - y1); a" N" G; O* S7 V$ I$ |
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);4 N/ }( v, t) r* R9 r' W& O
- pose.popPose();6 M# p2 b7 n2 q% j, K
- }9 a! V# p' u6 F/ y" \" @* I
- X* W! I5 ?. [4 M/ y2 c
- private RenderType getLayers(String texture, int light) {
7 F' y8 t7 h; W! A$ B" X - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
2 o+ j$ C7 W! \. ^# S - }( `3 B# X9 _# s/ m$ T/ e
- 6 L1 F( c4 L. S3 [: [/ P
- private RenderType getLightTexture(ResourceLocation texture) {
f8 t7 B/ r( S4 I5 \& D, e: i, g - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);1 t9 F* j1 \9 Y6 B- j$ D" _
- }$ d. q. y% R1 f- P4 q1 }+ Y! [, M
1 Y2 d' l: n$ ~. b& e# ]" p* M- private RenderType getTexture(ResourceLocation texture) {
6 b+ ~! y, E- S4 A1 D1 c - return this.cache(texture, () -> entityCutout(texture), CACHE_B);$ O/ h& n: l+ _! ]$ ?1 i8 k+ r
- }& u* I& i7 l- N& G0 r
, B& b) R% E3 R5 o- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
! i& `. Z& X. n3 ^% z - if (cache.containsKey(identifier)) {
/ Z5 d( n2 j; W, Q - return cache.get(identifier);
8 \$ p6 Z y) ^) q! x+ _; _ - } else {5 A; e" n. `9 P+ K0 \; K
- final RenderType renderLayer = supplier.get();
' c4 u5 ]! l1 k" n, K8 m/ W% } - cache.put(identifier, renderLayer);* _# @4 M k$ k5 j9 X+ \
- return renderLayer;% _" N5 N) B" x, m# f! a5 @* H) v
- }: O: f7 O8 K7 }- l. L' q0 s
- }
3 E, c3 X1 C8 N! u5 i9 C- C - }
复制代码 |
|