|
c ]5 J( A: b% f6 o+ ^行,这个怎么样
6 L1 m& V* h; O# `% ?7 u) Z- package com.xhg78999.mtrfac.render;% _( o! Y; w1 n4 h
- 4 B4 k* k d9 Z8 a' ^4 |
- import com.mojang.blaze3d.vertex.PoseStack;
6 w0 t' }0 O! P - import com.mojang.blaze3d.vertex.VertexConsumer;
5 W( T6 D8 V5 r! ?2 f, v - import net.minecraft.client.renderer.RenderType;
% I; Y9 d1 U3 A+ q- A - import net.minecraft.resources.ResourceLocation;
6 y: S4 v6 o9 x3 s H - , h n! M0 N: _8 Q2 h' I4 _6 ^
- import java.util.*;
3 V3 ^; S/ F. m2 B5 G. @( _
2 |- x- B8 {# @' ^& V+ ^# b8 B- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
% T. p, z! ]+ h( X$ W3 f
2 G) C0 j8 }7 W0 O1 h/ b- public class LineRender{$ p, C4 E6 G$ u$ b1 O* u
- private final PoseStack pose;6 j( r, V) x' e1 q
- private final MultiBufferSource source;8 D. j" A3 G) r0 n% |& k& i
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();* o* k) k/ Q9 A: j6 G# ?3 j- a
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();( b, j2 |9 I# X" V4 t0 O
- " Q, x8 M6 D) e; P+ [. N3 T: R
$ t8 r( d$ W& b f- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){3 Y, z2 Y& |: {5 `7 O8 ^4 c
- if(x1 == x2 && y1 == y2 && z1 == z2){
, G7 W1 P4 y9 @$ X( c8 p8 ? - return;6 T4 f/ d6 p5 F
- }2 {6 F' R/ u8 C
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
2 A& k" E& v+ |* D' \# { - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");5 i8 g& y1 r. z8 }
- }0 l0 T0 x4 b, s; R3 \
- pose.pushPose();1 k5 ]2 T8 |+ ^2 z: X6 F8 G
- final int newLight = convertLight(6);/ m' i3 W+ H; h. X: }5 y P
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
( ]/ `) N+ ?& ^7 X4 T/ x - final float lineHeightSmall = (y2 - y1);
5 z1 T+ j3 {+ Y8 j c: }* B - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);# A8 A3 n" u/ B
- pose.popPose();% [8 a2 i4 Y N3 l
- }
# E8 g1 H. J. S' Q0 o% |, b
# y$ j5 S; f& h/ S- private RenderType getLayers(String texture, int light) {
. @5 D- Z! Y- v - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
* R. P# h8 ?: v3 P( f B; H) P - }
+ d+ M2 y0 P2 s6 ? - : l/ f: Z# W5 v
- private RenderType getLightTexture(ResourceLocation texture) {
0 y8 {5 U' t% y2 m- X" ~3 w - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);* h% B$ [) _$ w! o/ d6 f
- }
% t$ w' i+ e1 P B( e+ \ - & l# ?6 T" i D9 L& D2 Z9 M3 x) h
- private RenderType getTexture(ResourceLocation texture) {
- E6 ?) n; m- H - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
& _2 N* O$ X. H+ w& x4 x - }+ ?! z$ }% M! v) e+ N% l7 e
- Y% W! M6 H1 N# H3 Y5 m; f8 r5 l
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {+ B; t' g$ M+ ]" ]# g
- if (cache.containsKey(identifier)) {- W, s( T8 j) {
- return cache.get(identifier);
$ P$ ?9 i2 s& |+ B- B - } else {
- U! }# h( x2 E" |. z$ H; Y - final RenderType renderLayer = supplier.get();+ G' W+ ]5 D: w6 n6 b
- cache.put(identifier, renderLayer);
, y' n# b; D/ f* x( L - return renderLayer;# v# z" Y C" F* \
- }
5 U; b5 q2 k& V. \$ g8 { - }# X( d9 U* I( g9 w+ c; i0 G/ r- C
- }
复制代码 |
|