|
|
6 ^8 X3 q8 ^1 \' I8 B
行,这个怎么样% W5 }2 W" X: {' R
- package com.xhg78999.mtrfac.render;" R7 A' Q% Z0 \+ g+ U/ g& U$ T$ u
- ' P" h+ K' v7 `0 t; ?; X5 E
- import com.mojang.blaze3d.vertex.PoseStack;
- }, \0 Y/ b6 _+ j) s - import com.mojang.blaze3d.vertex.VertexConsumer;
# [- [. [) k6 | W - import net.minecraft.client.renderer.RenderType;
/ C' ~* n) R2 ^( E* V- Y, U - import net.minecraft.resources.ResourceLocation;
4 F7 X W* b# ?. M0 L - 9 y* x: w+ z0 ?) T3 j" `' G
- import java.util.*;$ ]( G |# [& o2 [$ C1 e4 s- y, p
) E, f) R9 W, `* C, [- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
% ]% A* W4 {$ Z9 L$ ~ - 7 j% A( V) E( K
- public class LineRender{
* s) b# \1 b8 \0 \ - private final PoseStack pose;
' ]3 C7 [9 O9 ~# P' L - private final MultiBufferSource source;' d& I2 a! T. E% W! x6 s
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();$ m# u: l% l. D3 l9 x4 W( ~% R
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();& \- ~6 w, Z/ z1 B
% b0 G. J% }+ K5 j: X- # k$ j, y6 Q; g. P+ ]9 ]4 Y% B3 t
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){: R8 I6 E- E% V- A& @6 i# |: l3 t
- if(x1 == x2 && y1 == y2 && z1 == z2){& P3 w7 |0 K4 H! t* N
- return;
& F1 l1 i( N+ a# ^; B - }
# ^6 g0 ^ J$ _! E& h5 B- _% i - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){4 l) a; l& a- |
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");0 h8 M. Y3 T% g+ J1 l* V* j
- }
1 T. M @9 r- S8 } - pose.pushPose();
: t3 r. d/ |8 A" F! @ - final int newLight = convertLight(6);
! T! Q' l' d- q8 W$ p% f* T - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));" ?+ i1 o( r9 v6 T/ K
- final float lineHeightSmall = (y2 - y1);; K; [, {: C5 I7 x" \+ Q! i
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);5 {! w+ Z0 A0 P; O* Z$ h: u7 A1 Q
- pose.popPose();
+ Y! E6 {8 r( W1 B: X - }/ G6 e4 Y. `/ t' ]
- * F+ E- A( M+ w$ X/ H+ y3 r0 |
- private RenderType getLayers(String texture, int light) {0 W. l9 D8 o( i7 L0 C9 s
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
. O, j; C7 T, Y! C$ g - }
/ M' I6 a. m; u; V; ]+ Y - ' U' o. t* T+ D( o! q4 R& S7 U
- private RenderType getLightTexture(ResourceLocation texture) {
( e g; V! E) S+ `& H0 |: X; ` - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
( j; ?8 x) [6 M+ m+ X - }
& f; U- @* ]6 p5 r - 9 C, N" z# u- D4 I' _
- private RenderType getTexture(ResourceLocation texture) {4 O5 X) M4 a6 V: t7 Q+ i
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);6 Y% e/ F6 A& S5 G/ H/ P
- }. q% ]* f. I/ u' h
; f7 ~6 I) d( C- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
2 y/ q6 N) q0 c0 |" G3 Z! ~ - if (cache.containsKey(identifier)) {
% D. ?3 v# t/ }/ F1 A; r: u. _- \ - return cache.get(identifier);
( S( ~2 @3 X/ N. a$ C1 L - } else {9 {4 E% i5 I7 v. L
- final RenderType renderLayer = supplier.get();
5 `( m) E! v, @5 S) o# u" U - cache.put(identifier, renderLayer);
- L' F0 z) }% Y6 L2 w1 j8 _: J - return renderLayer;
1 d) C3 b; P+ z$ I2 O3 n+ n - }" J X5 @# T( F1 e3 h; [
- }* \0 _' _1 ~) N8 z% a& `) S
- }
复制代码 |
|