|
|
: _% P; `0 n3 {9 W* X
行,这个怎么样7 B! t8 v8 K, g
- package com.xhg78999.mtrfac.render;
& @: S8 [) ?/ Y6 N
3 k! a7 N5 H7 P* D- q8 y! z9 L- import com.mojang.blaze3d.vertex.PoseStack;$ S7 @& t) P, ?2 z' `
- import com.mojang.blaze3d.vertex.VertexConsumer;4 s* B1 A+ a# @5 I+ [
- import net.minecraft.client.renderer.RenderType;7 I, r: @( x/ S5 U$ w% M/ k1 P
- import net.minecraft.resources.ResourceLocation;8 a7 o3 l- r G H; g" G
- 7 w. Z+ `% @$ h
- import java.util.*;9 @7 d* I5 y% p
5 L8 B3 X4 E& G2 c- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(. i& ~7 |( b* i) g' d! W
- . ~2 o$ Q9 T4 M1 ?4 O/ S# n
- public class LineRender{
! I- B6 a; k" `; U - private final PoseStack pose;
" T2 w( S2 R! c% Q# v - private final MultiBufferSource source;
) _0 ]3 r% t* O( ~ - private static final Map<String, RenderType> CACHE_A = new HashMap<>();3 E5 y5 K9 o# I; U- }+ X
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
4 B! c" @+ R6 x! k; a5 k5 H
8 U+ ]6 S9 `$ E1 u& f' K. f4 ^- ; n/ [7 j1 `; U, j& E) \
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){+ Q: o* D/ Y- V" O2 V! u
- if(x1 == x2 && y1 == y2 && z1 == z2){
$ F4 w) ]) B' T! P - return;
7 E3 Q: l" o/ T# V! s - }
! |) ?" `6 q5 H6 ] - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
; h3 K# J5 z* q - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");) \1 d/ A. n" G4 q" r2 o( l
- }& s/ o! x, v5 c) M4 h7 N& f
- pose.pushPose();
( A: Z; K$ x$ I8 z5 \/ F; p7 t - final int newLight = convertLight(6);6 t( D1 B1 ]9 P; c: G8 \
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));" ]* H( X- M$ i( ]: T0 j/ H, F5 P" ?
- final float lineHeightSmall = (y2 - y1);, U1 |8 r0 X6 w, x" o% \+ L- q
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);2 y _6 x4 K6 o8 Z+ R, x7 ^6 t
- pose.popPose();1 h+ ~ F1 _* n5 G$ D) o
- }
4 t4 D( z3 W4 H7 Y% A( X - 7 o9 _( k0 p0 f2 z: I
- private RenderType getLayers(String texture, int light) {
q2 g6 f7 r# Q4 G - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
# w+ N5 j1 S/ {3 ]/ s1 I8 j" Z - }
& G1 L- V% D+ \* p) u6 R, K7 ~
2 v/ ?& A, ]/ k- private RenderType getLightTexture(ResourceLocation texture) {" ] r. A- W! ^
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);' E- V- V4 A* R4 ^4 t3 t. c
- }
$ E1 }! y* S! m - 9 n9 R3 [& g$ u4 p' S* ~7 ~
- private RenderType getTexture(ResourceLocation texture) {
$ H( ^; x! j! `0 ~' P - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
* |0 p6 A0 ?. d( P# m2 y% o& v - }
( [& H6 ^+ A, u# Q! p' q
2 `& j. ~% y2 I- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {' ?' @7 b4 `1 ~8 L( L
- if (cache.containsKey(identifier)) {8 S q d* B8 M, l4 \4 Q
- return cache.get(identifier);
6 ?, ^0 K7 F: a" S - } else {; K! e4 b4 S; N+ G
- final RenderType renderLayer = supplier.get();% I6 S$ A& o3 h- s1 y
- cache.put(identifier, renderLayer);, b0 x: {- I/ P$ P
- return renderLayer;% K: x- j) G- q0 \' a( W( t/ c4 W3 L
- }
3 X$ m+ \ ]2 M - }
. U; p, O( t. x8 ~% { - }
复制代码 |
|