|
|
5 r- j" R2 E: B( A/ H8 [0 f行,这个怎么样
0 x' Y4 b" g N& Y1 s- package com.xhg78999.mtrfac.render;
$ k. d7 {/ Q8 _0 x3 v
: X5 S" g- P9 _ f2 f+ a/ C- import com.mojang.blaze3d.vertex.PoseStack;9 Y/ n3 z; B! A' A
- import com.mojang.blaze3d.vertex.VertexConsumer;
* o# Z& k: s$ J% b: F: k( [$ Y) A5 i - import net.minecraft.client.renderer.RenderType;
" [$ T% R [* n: L7 s' ? - import net.minecraft.resources.ResourceLocation;
8 r" d/ U/ m, {( t! ?* H- b - 9 M. C1 z D. O; g
- import java.util.*;" x7 p! x( V/ K& d' h, [
8 L! R& w6 e% T8 c* x- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(0 n% g' v* J4 v' w7 X* S% M! l
- & N' y$ M: H0 w1 S/ b' @
- public class LineRender{
- {8 q: z7 G( f - private final PoseStack pose;
- ^$ X% q' e+ y4 k: y - private final MultiBufferSource source;
' q, `3 B. B1 M/ h% T o - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
: q. _0 K/ v& p6 B. G' l" B - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
1 U2 q: y4 K y5 W4 F
9 M/ `; \, R- {8 m6 x8 u- ( O/ m5 i6 ?! Y2 I9 M+ O4 [
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
, a, L/ C8 n! ] }4 ~$ r - if(x1 == x2 && y1 == y2 && z1 == z2){
* u2 Q1 Y6 m- e1 k2 F - return;
9 f" Q3 b" C+ X8 W9 M. g - }# m m" C) a; @$ B* ]
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){. F3 m! K# \/ {+ x
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
; Q3 h, W! N$ g* l7 I9 H - }$ ~9 _' i: x% f, X& C8 E D2 j
- pose.pushPose();4 ^. e5 u; w" h% k i7 Z+ m
- final int newLight = convertLight(6);8 R/ F2 m+ b0 }1 j% ^5 a) T
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));1 P& k' g8 }7 ?8 V& A4 \0 n% O
- final float lineHeightSmall = (y2 - y1);
) ~' L1 Y$ c6 C, | - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
) y) y# e5 {8 C) E - pose.popPose();
1 `& q V- ]( e$ J, \" X8 ? - }- W8 L) K' d2 a9 \* Q4 m! \ m
- $ l: U9 ]+ `5 r) b/ |0 b7 U
- private RenderType getLayers(String texture, int light) {% t' i* G. h; s! I7 _- ?8 K4 S
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
. p1 f' v$ h8 v" Z+ l& V - }/ Z! r& }# P2 P* D
/ A2 c9 A$ [" l! }. @/ ]& T- private RenderType getLightTexture(ResourceLocation texture) {8 ~0 n4 V' q) l' x) y1 t* q
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);8 o3 a, O* W7 a
- }
4 T# ], g: T7 W9 A" }7 o3 a - & f1 m. M8 ?) c
- private RenderType getTexture(ResourceLocation texture) {$ a5 I' l. C: R4 ^7 C/ V$ M( z- o
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);. a5 Q. }* y- R1 b
- }
% U* e8 q* }1 ~8 k
! e, Z Q! u0 D' l& {: k- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {7 t* n/ W) ~) P6 x9 T% x5 e
- if (cache.containsKey(identifier)) {& o! i( n0 E5 z# X3 E
- return cache.get(identifier);1 O; S3 y, B5 f- z( a
- } else {
; _0 e% K9 c1 o) R - final RenderType renderLayer = supplier.get();$ u0 h8 n' s$ \) q
- cache.put(identifier, renderLayer);/ U/ E9 P8 d5 N; {: m" V( ^
- return renderLayer;+ b4 B6 y7 n9 y* [
- }; ?( t+ f: m- _6 E
- }/ X; |$ N- e L
- }
复制代码 |
|