|
|
; |" U9 ]* R, J3 E- I
行,这个怎么样
! h0 \9 n3 n1 h- package com.xhg78999.mtrfac.render;& t4 P6 { y- q7 Z1 E) g
- $ J, U2 @# y W8 S* }, j: J. k: W
- import com.mojang.blaze3d.vertex.PoseStack;
f- a4 z# a, `) R5 A. H0 e6 G - import com.mojang.blaze3d.vertex.VertexConsumer;- ]+ `3 b3 {1 E& T
- import net.minecraft.client.renderer.RenderType;
* ~% r: C2 C1 f - import net.minecraft.resources.ResourceLocation;$ u; Y5 [* d7 t' s# \$ u
$ v% W4 c- S2 \ |( f5 y, i) `/ F- import java.util.*;- o1 e& c+ J3 x; o W, H
0 D D. G6 n: ]' g2 |- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :($ T7 g0 Z) ]6 J: s/ L8 z' Q2 z; T
( r8 {& B) v1 l+ Q- public class LineRender{& T" K3 }8 F% W( r: X5 @& F' l
- private final PoseStack pose;
9 W( j5 _1 b% M( S2 P+ ~ m9 w, p - private final MultiBufferSource source;
% S/ ]" ]1 S& B5 Y3 x - private static final Map<String, RenderType> CACHE_A = new HashMap<>();" T- @5 ~, g! L% _% ~2 m: W. s4 _
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();2 b+ v" I( A2 w) G: U+ z- X
/ P1 G. |2 e1 q" W9 ~7 i- e- ) @' W" S7 `" u: M7 x) @( {' R; r
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
# ^. f) E: V: }2 a% ^; d+ W+ A) s - if(x1 == x2 && y1 == y2 && z1 == z2){
! `; n+ K) v, J' ]+ R - return;) v4 T& T: w6 I8 {* ?. K
- }
8 {5 n" r" ?1 U5 W f+ F. J: l, \ - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){* S& v' [8 @5 [6 b5 r% V& L
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
& E' T7 X1 u% _: p( L) I, l5 I - }4 F" U% X# a. y5 w" Y
- pose.pushPose();
2 t4 U4 F5 U n; Q5 }; a - final int newLight = convertLight(6);, k; u2 B* _( K- t t, H- t
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));3 l& T2 t3 t9 b* C: Q/ r
- final float lineHeightSmall = (y2 - y1);/ ?) @0 w* \. }+ J2 d0 w% J
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
2 h1 T' l& K% f- O! \% M7 n - pose.popPose();, X) }( H, u5 M4 P- c$ ^, `# G
- }
$ }8 m) j7 e" [' i+ p3 O; |/ y
4 @) m9 b4 E4 n- Z2 z7 h" C- private RenderType getLayers(String texture, int light) {
' z4 ?, E. K3 v5 T+ o - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
/ T# i1 Q% a/ t# e - }' W0 H' x% x" L4 g
- + D: x! d8 G3 k* q: w; z6 Z
- private RenderType getLightTexture(ResourceLocation texture) {/ E* d" [8 N. `- `5 l" i0 N7 N; {
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);: p- M4 F; Q4 Q( _4 I' q2 O
- }) }# f3 C+ W0 e+ F" F k+ U% |
- $ u4 v% `/ p! i) Z1 b: v5 E; M- h, P% j
- private RenderType getTexture(ResourceLocation texture) {
( `! C. X0 S9 T/ p# C5 x9 \ u - return this.cache(texture, () -> entityCutout(texture), CACHE_B);0 ]" M: t. F# ]& ?( Z
- }% \; I) S0 M2 C
" x7 w( x4 _3 P" Y7 |7 d* j- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
1 q5 D7 w) j: O* j3 G) o* y. v: u - if (cache.containsKey(identifier)) {
) L- n2 p6 k O1 _, K' G, b E3 b - return cache.get(identifier);1 [( T# {: \6 v* g* p
- } else {) c! ^7 }( A& W# C8 B
- final RenderType renderLayer = supplier.get();) }3 |2 R: h' v1 x
- cache.put(identifier, renderLayer);
0 [" h/ }9 j$ `# ~ P - return renderLayer;# R" C8 A/ ^2 E1 r' }
- }
( X/ H9 q4 Z: q5 W6 N+ r+ q3 g - }
1 \4 v: r2 O4 k8 }1 P/ G - }
复制代码 |
|