|
|
F5 M4 H! {" ^' u行,这个怎么样
& [. p3 A, H8 w+ n- package com.xhg78999.mtrfac.render;5 e4 r) w. N# C1 y9 ?
- ( N. r t2 Q$ k" O1 \; Y& q
- import com.mojang.blaze3d.vertex.PoseStack;
0 ]8 G8 I, J! t" _8 @2 S! F - import com.mojang.blaze3d.vertex.VertexConsumer;
* k* P/ e" l' @* ? - import net.minecraft.client.renderer.RenderType;
5 a# {6 S& P; m" o' i - import net.minecraft.resources.ResourceLocation;
( p3 Y* K) K! q) t3 d
) m8 y! g! j Q/ W- import java.util.*;* k3 P. R& `) M; E, u5 X9 S+ A g
- ) p8 x! r3 o- n- p4 h& ?
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(1 W* I: \6 ]1 f# u' C& `
- 8 u! J9 H% d" n" {: Q% i, s) w
- public class LineRender{+ V* M7 S& e4 p! l
- private final PoseStack pose;* w9 W- |9 S- }; C5 x
- private final MultiBufferSource source;
& J! }: e3 X5 q8 v1 R3 K! p - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
4 _; N @. A, { - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
4 m8 X) Q9 E9 C" v* U
3 j2 i8 g# G8 Q/ o- ( E" d2 Q# X3 A- g
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){' _( z0 @2 Y3 t( d# a9 `
- if(x1 == x2 && y1 == y2 && z1 == z2){
+ \6 v9 p# M, Q: Q - return;
& _7 v* i8 W1 X$ _) y - }; a" a& |2 a' g, Z6 Y+ Y( M/ m
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
: i5 ~ X" s4 |# F/ |4 Y - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");0 N$ X) N# f i4 l2 p5 g( h
- }& K* @' K8 a) E8 M z& q7 h ]2 o
- pose.pushPose();
0 ?- ?% K4 I; K) L - final int newLight = convertLight(6);
2 f% a. n- p1 X! @( o5 H - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
$ O: u8 m( d6 A7 a0 k" T - final float lineHeightSmall = (y2 - y1);
- C( l2 b2 y5 P8 t - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
$ F8 _2 e5 R9 D6 g+ u" j' S - pose.popPose(); t' l! w' a0 n/ {2 X
- }
. p9 [* w: y* H2 B3 G3 P' u
M. _5 A4 i' ]4 X% T$ G- ?: `- private RenderType getLayers(String texture, int light) {( A' q! n* T; C3 ?8 l
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
# M J, B: F' E2 c9 {( I - }( |4 `$ y% P: T& L) o
9 f3 _ v& A, F/ |( c: r9 g \- private RenderType getLightTexture(ResourceLocation texture) {0 S! F) c. u) R$ K8 [
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
$ m. g% P/ L- y. I. A4 W4 t - }
) R; m- p4 L9 I/ z; b
: a0 V# u* y5 \( w5 P0 J+ W- private RenderType getTexture(ResourceLocation texture) {
/ ~+ o# X+ O3 _; a6 B6 o. v - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
4 {0 H* [ n; A2 h - }: o5 h9 C9 b) c8 H( Q f
3 g- Q2 }* v1 e" W7 e- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
3 z- H2 [& G+ b - if (cache.containsKey(identifier)) {
* B+ {# n( K' p- r8 x+ |3 q: B - return cache.get(identifier);
9 M% v V+ R9 K$ J+ M - } else {
) A9 `! p, C8 ^- k5 u2 W/ v - final RenderType renderLayer = supplier.get();. i3 P# A# A& o8 b% d8 R/ K
- cache.put(identifier, renderLayer);
) H2 E4 L3 U- U, M5 J2 M - return renderLayer;
/ q. ]6 @- q% k( m - }
$ u" w2 I* J& D- H - } J- v8 }1 o3 G# ]
- }
复制代码 |
|