|
|
+ ^. z6 J3 C2 H8 J5 U. |行,这个怎么样
# y, Y) |' Q4 H" f% x; E. w- package com.xhg78999.mtrfac.render;
, k# y/ _" a: Y3 Y ?# l( r: e% T) h
* @, G1 e/ m; a5 A# s' o0 p- import com.mojang.blaze3d.vertex.PoseStack;
7 X1 Z1 @0 y$ B( t3 @. i; ^( Y - import com.mojang.blaze3d.vertex.VertexConsumer;; z+ f5 [% k% B
- import net.minecraft.client.renderer.RenderType;
0 y' i( m6 N+ s/ K& ` - import net.minecraft.resources.ResourceLocation;
% R. F: [2 y4 V' i" u% u( Y# h
( ?* g+ L8 k7 X" s# S- E- import java.util.*;
4 V4 A7 w" W W) g4 }& V. b7 w - P& w5 Y: d* A4 l0 G4 T
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
2 i7 R( T& d$ t, I1 N - 9 p5 i5 n% t) B% X, X/ U, H
- public class LineRender{8 o' v/ h8 `9 {- f1 H
- private final PoseStack pose;) M8 F; f8 i7 }1 h+ |9 W. u
- private final MultiBufferSource source;
) S5 x. ]( }7 U* e3 }# g - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
% `# A& p' f3 p k$ I" w- y4 X2 a* x - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
5 n; A5 N: }! Z7 Q z) I2 S - 2 y; s4 Z% A9 E; v
$ T2 Y: w5 {& w: p5 I0 l- |- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
% M5 E, {; v7 b% k* m: Z/ X - if(x1 == x2 && y1 == y2 && z1 == z2){
* P9 B( H/ f8 z" H2 ?& m! q - return;
/ Y4 G) E' h' x/ [8 z - }
9 ?# k% T/ d, f( t9 W - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){ u r: |& `8 s* l
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
7 m! }; m* i* x$ R7 L* k: k - }
7 d5 o2 \9 r1 U$ p- S: ]) _5 i/ i - pose.pushPose();
& @" D. o( {5 u3 q! |, t - final int newLight = convertLight(6);
8 a1 Y. F! I9 i/ t1 m" [# H8 g+ l - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));- D, f+ @; x" Y" ^4 s: A
- final float lineHeightSmall = (y2 - y1);) F/ Z( Q& w" J2 Z
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);8 Q7 y4 [ L( Q& l1 v! w; y0 g
- pose.popPose();9 D: i# M. U" f7 I1 e0 X9 H
- }: m, j( ?3 F# k! w* q
8 i" ?" [ t$ t8 v- private RenderType getLayers(String texture, int light) {5 ]! T; u- k" M. V. F* w' W: S
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
4 O3 u- n% r( `; c4 c* i - }; h# X& c5 \( u, o1 `0 T/ P
- z' _, W/ G7 Y4 x/ v* \- private RenderType getLightTexture(ResourceLocation texture) {6 [+ S T- N6 \
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);( d5 u/ L8 I0 d. \# Z: A
- }$ h& E5 g l- R M
- ! Q; k* W/ X" ~ {5 F
- private RenderType getTexture(ResourceLocation texture) {9 X2 G: Z6 h+ Q
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
" F+ ]( q8 u% b. H - }7 O) b' j7 {/ i0 W- M% U! G1 ~
! e/ _6 o( `0 a$ y; y- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {% V6 C9 A- B& F
- if (cache.containsKey(identifier)) {/ f3 S0 C8 M3 C
- return cache.get(identifier); I) M6 U' I2 o" s. [
- } else {
8 e$ ?! I/ ]: u) i2 C) \: B8 B - final RenderType renderLayer = supplier.get();2 a& _4 ^9 d- [% ]' Y5 Z
- cache.put(identifier, renderLayer);
% t+ `0 e7 i3 \2 l2 B; v1 q) n0 w* ~" w - return renderLayer;
1 P+ |: G1 [+ l j9 N( D - }
6 ]) d3 ?/ [& v" [( Q+ G, F - }$ l9 r9 j* e5 ?1 l% Z+ V3 B" U
- }
复制代码 |
|