|
|
( D2 x, ?; i& g0 r行,这个怎么样' l: ^. {0 j$ C4 g* j9 [( N& H
- package com.xhg78999.mtrfac.render;
1 q) _! E4 p& y8 ~8 Z - 9 P s' N5 s; W! b# S
- import com.mojang.blaze3d.vertex.PoseStack;: m( Q* \& W& @
- import com.mojang.blaze3d.vertex.VertexConsumer;# Z' N$ r- D6 P% L6 l1 x
- import net.minecraft.client.renderer.RenderType;
5 o7 c$ S( Y2 r - import net.minecraft.resources.ResourceLocation;: J0 K4 V3 n2 S) ]$ t
: U9 R a6 B' S1 f+ O. Q- import java.util.*;
) C% a* u: T9 e" u. J# m: J7 t9 `
* a) F6 g4 m+ N3 j- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(1 M6 K! O. m* V
- % b: K3 z4 i: O( u
- public class LineRender{ X. u5 G& B( G; r- M: Z" i
- private final PoseStack pose;
) B! |* h0 s' S' @ - private final MultiBufferSource source;% ~4 c/ w4 d* S6 y
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
) G" I! a+ v, T; r; [% I - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();8 b- f- b" H& k
% Y* I$ R: A. g
+ B4 [5 V. b4 I" L- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
; b7 n5 v; n2 @( B9 M7 W - if(x1 == x2 && y1 == y2 && z1 == z2){# f* K3 j3 N/ R! [" n, A7 Q+ Q Q
- return;3 ]: I& m3 d% z3 G
- }
' g3 [; K8 g' q. m - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){$ P3 f F: k( q3 M
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");/ T0 w u- N; Y1 X4 L: X U
- }
3 K4 f) C, j2 }( J: q M - pose.pushPose();
2 T+ b+ z. W% k - final int newLight = convertLight(6);
4 r" \) ]( Y$ V - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));( a8 L; Z- q W' B
- final float lineHeightSmall = (y2 - y1); P) e# h+ D7 }$ a5 |
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
' Q3 c. j+ \0 x; F" O+ ] - pose.popPose();& {0 G; p/ z7 W4 L: F {* \
- }
# A/ o) w0 G- s" d, e
/ X) U/ n4 A' M7 D$ l6 a: A. K6 E; i- private RenderType getLayers(String texture, int light) {) F2 k+ o( r) Y8 z9 A
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
6 q; k( N! Y; Y! J5 f, H- r - }
+ z4 H7 ^- V) Q0 m# G
$ V0 X3 ]) v& @/ i- private RenderType getLightTexture(ResourceLocation texture) {: s3 w: |/ A! n9 A" f
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);3 T" r+ Y2 ?& _$ u% `8 o
- }
$ V/ f6 ]* T; L7 }
( G% [( P+ [* z8 ?- private RenderType getTexture(ResourceLocation texture) {
8 w2 h, P( E* h/ v$ I8 N8 { - return this.cache(texture, () -> entityCutout(texture), CACHE_B);- ~8 a4 ~6 Y: Y3 e
- }+ a+ d* I8 M% K1 K
! N. j+ f& p) n( }2 x/ F" _- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
7 n# P1 z6 O" g. q% Y - if (cache.containsKey(identifier)) {
1 |5 `) Y4 ~4 R3 o9 ^, Z9 P1 V - return cache.get(identifier);
) g5 V! M2 g/ s0 y8 h4 t - } else {$ K: r/ Z- f: \& |- [) h
- final RenderType renderLayer = supplier.get();
. \9 t0 @) {/ C+ E0 l$ k - cache.put(identifier, renderLayer);
! E0 F7 M$ ^/ S2 F% q6 A - return renderLayer;
/ W% q& o' J3 Y: @1 Y+ K - }
' g" @) J! l2 H9 u - }! ^. K, i1 L- m; k* v" k& U% Z
- }
复制代码 |
|