|
|
) b H+ I, E! [
行,这个怎么样
! H) U1 L6 U7 n% B; E% t$ j! [- package com.xhg78999.mtrfac.render;; K# `, {$ q1 l# {0 w1 E* [! z
, p$ `2 H) M2 v$ h- import com.mojang.blaze3d.vertex.PoseStack;
8 H* z3 u& v" a; G' z - import com.mojang.blaze3d.vertex.VertexConsumer;, T3 p) Y: o4 ~8 y; K
- import net.minecraft.client.renderer.RenderType;1 l8 l( `7 V% a/ a5 w
- import net.minecraft.resources.ResourceLocation;
# S5 L( x6 A, \* Y
* M/ ?( S/ u, s; ]- import java.util.*;
$ j8 l% Y1 G, G0 c6 {0 Q5 p. j - , c: W" R* t: E" y
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(% D/ @% D: `) h) i! I ~5 i1 e
- 4 W. @# B2 p" A4 m8 o. c
- public class LineRender{8 L6 ~4 k9 P. U/ i& h. D9 m
- private final PoseStack pose;: x8 I) T+ y& r q
- private final MultiBufferSource source;
S) W) t0 R& J7 _8 e! e3 o - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
$ V/ m" Y9 \# F6 h1 ` - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
: z" z* _. f2 X; Y- R - / \ r4 J9 m- r% a- {% r" \
. u( ^/ P& z( ^( O- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){# a. e: ]8 }+ c: [0 d1 P
- if(x1 == x2 && y1 == y2 && z1 == z2){
: c# M, e; u, m: t( t - return;
% s- W" E: V. h O U ~( I% _ - }; N6 k3 n: ^( I2 I
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){9 P: h7 x4 D$ x+ h' G7 E
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");( J d4 o4 }4 S D% Q: ~5 P* L
- }4 \9 e2 Z) A& o* j1 Z) q; a
- pose.pushPose();1 f' P0 @$ _, V
- final int newLight = convertLight(6);
& D$ x( u1 Z' K( y, W- a - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));2 F. j2 ?& `0 N3 V# @ W9 q9 }' q
- final float lineHeightSmall = (y2 - y1);$ S$ v, Z$ k3 |* G
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);4 \( Z5 b" a. g7 }, @% Q
- pose.popPose();
8 `% t) t+ R- A" P- F5 B - }/ e, t9 E6 F* H3 i
" q+ _2 E7 k, I$ H$ V4 L2 u- private RenderType getLayers(String texture, int light) {" y( r/ w6 V }$ _- F
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));2 k& ]8 v$ Q+ i; l! s' r
- }+ r$ I5 V( P# K& y( [) B5 t# j8 g
* G9 g, C2 h" C1 ~9 |- private RenderType getLightTexture(ResourceLocation texture) {
}9 [, L; {5 p% W4 {% }& Z - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
; g1 U, ^% G0 ] - }
7 J. T4 l$ M) x# [- N( b, B
! M9 h0 i- u5 X: Y% P3 L$ K- private RenderType getTexture(ResourceLocation texture) {2 K7 b. ?7 J; m3 O* l7 F. m- V
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
& L4 J& o6 R; c$ b" B2 a- c - }
. `9 R+ f) F9 e" k
' x$ g( H& y: s i- D# r2 t0 N- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
$ H3 @8 V( N R% Z# E - if (cache.containsKey(identifier)) {
7 g* N# |$ L& x V. Y/ r. q) E/ N - return cache.get(identifier);
/ R1 k( ~0 h, [! v! ^; ^4 W - } else {4 H1 ?4 W8 H5 O$ Z' x) [ {8 q0 b ^/ ?
- final RenderType renderLayer = supplier.get();) r1 ?: W& d& |" ]% A: ~
- cache.put(identifier, renderLayer);* r, N1 q+ Q9 A3 _; m
- return renderLayer;- W7 L5 Z0 x- k% W8 G3 O' c
- }! m2 h! ~% Q0 }) l5 U
- }
! r& c* x! r+ j3 } - }
复制代码 |
|