|
|
. l7 m) F" U4 _' U行,这个怎么样
- z1 W; I& Z% i- package com.xhg78999.mtrfac.render;4 R+ ^0 C( e+ d, {. k7 M
: W6 ?4 u' @+ r- import com.mojang.blaze3d.vertex.PoseStack;
7 f, X) y. |6 D' G( Y2 B1 f4 @ - import com.mojang.blaze3d.vertex.VertexConsumer;/ N5 F1 t0 m+ }( R- w5 v( R
- import net.minecraft.client.renderer.RenderType;. |, O! n6 z5 B# R% J# D, b
- import net.minecraft.resources.ResourceLocation;. S* D5 V( U; M, S& \5 U) L
- ; T6 m" C) y3 W9 I7 B
- import java.util.*;" a. i; V- q1 x1 j4 d- D) m
3 `& M0 c9 d9 u1 X. n" B' E6 n- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :($ C$ k' C. Y* t `; [; i$ y5 ^
- 4 u. P- D' T, o4 d, h
- public class LineRender{
: \ r* w# T" { - private final PoseStack pose;
/ p' z8 M, n0 L - private final MultiBufferSource source;! S: A" h# D5 F
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();0 \% U5 G0 m7 N' z
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();4 X+ a3 p# z$ k0 [# i7 m
5 A [* Q3 ^$ Z3 {; [- 4 z2 j- i0 Q" c, ]
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){% C% f) a! P# u' Y6 p
- if(x1 == x2 && y1 == y2 && z1 == z2){% U. m0 H k2 ?
- return;) `4 a( a' s# {' P& `
- }: {; r2 D) ]2 e. @; P; ^
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
U9 M3 T6 r; l5 O+ K - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)"); u2 i4 v+ \7 m5 ^1 F
- }4 i- y+ a( j$ G0 f
- pose.pushPose();& W' s. x/ s$ h0 m
- final int newLight = convertLight(6);3 b9 D, e+ c4 I) s
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
% D7 H3 w% C2 G0 O4 I7 \+ ? - final float lineHeightSmall = (y2 - y1);
! |+ ^8 k+ o) w9 L5 Q$ L - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
+ N1 v+ _/ O+ B' \6 } b6 { - pose.popPose();
6 t5 J! ]# n+ o$ ]2 \" h - }7 c; B+ J/ q. z
- . K a. ~8 A0 u8 `; S8 c
- private RenderType getLayers(String texture, int light) {% P, l4 \- _" z+ R: x
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));4 C& q/ e e- v- ?5 h5 q
- }. T4 _' K6 f! {/ R0 h
- 9 D' ~) {+ A$ B% J5 `) x# @
- private RenderType getLightTexture(ResourceLocation texture) {
2 }) p9 f# ?, Q4 K, g. ~3 w7 x; Y { - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
" ?2 I/ G+ F: W+ B - }) [6 a$ a/ c0 n/ ?6 ?: t
- " m9 l8 d8 C& Q( H6 {) m7 Z
- private RenderType getTexture(ResourceLocation texture) {
- c4 k# D5 O6 l - return this.cache(texture, () -> entityCutout(texture), CACHE_B);5 ]4 v; W2 S# ? `2 f& A( ^* N; r
- }
0 N; M8 @* g ?# e8 o
& }' l7 \$ ~8 l! l+ b- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
1 |2 [" x) C, ?5 _; n, R0 O - if (cache.containsKey(identifier)) {9 a" T" I# U* s B$ {
- return cache.get(identifier);
5 n9 R( [: G7 t3 R# l - } else {
+ j& K- l, o4 }2 X - final RenderType renderLayer = supplier.get();
+ U7 c( {& ]) K7 H; y, C - cache.put(identifier, renderLayer);
! N* \$ c4 a# k+ c - return renderLayer;
, Z7 ?5 j$ o! w1 ?: J1 u) V- S8 E* ] - }
# a" u) j6 a( P4 j - }2 j2 {* U. b2 o% U5 E2 m
- }
复制代码 |
|