|
|
( p8 ~' N4 n! ?) G* y, @行,这个怎么样, J- ~) G' \. D$ l
- package com.xhg78999.mtrfac.render;
9 i5 n5 h% _3 H, A7 O - ) c0 B, g6 n' |5 ^
- import com.mojang.blaze3d.vertex.PoseStack;4 R4 p3 b( [1 ~$ m0 e I
- import com.mojang.blaze3d.vertex.VertexConsumer;
: `6 s8 `6 @- W( i- |6 C - import net.minecraft.client.renderer.RenderType;
]1 {* ^; R( ] - import net.minecraft.resources.ResourceLocation;; Q0 [$ Z) A# G2 v1 s' d1 a
6 ^5 s* i# X4 c; b. W( g% p/ t6 H$ Q- import java.util.*;# K% M$ n+ g3 o! J
- 0 n5 x; a- b6 B5 o& O; f. b' [% O! e
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
& Y1 ^1 A+ P1 V3 ?: ^3 B" m - $ ]$ ^ r1 y1 n3 ^
- public class LineRender{
1 j. R8 x* E7 ]4 C% c! c5 V - private final PoseStack pose;" ~ o/ ^" h* T: r
- private final MultiBufferSource source;
1 d9 Q( k, Z4 t9 [) c - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
$ c: n5 G- {& `8 f# i% p$ n - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
# W2 n# W6 q) ]' G1 `. y$ H - E" `- f# X3 {1 X
) p6 t; t4 Z6 Y* o6 P; w9 ^7 G- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
0 c/ a# u8 N% `! e J - if(x1 == x2 && y1 == y2 && z1 == z2){: u9 _/ P, ^: w1 r. Y
- return;/ s& C) ]& L* f# I" S
- }
5 ~# W- }$ d& V2 }- g9 p - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
$ Q5 L& D* |( a1 M2 @0 ~: S2 O - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
- ?' T* e# b7 L. k( c) {% h( a - }( h) x, ?, u% h/ r; M# U
- pose.pushPose();
2 @8 c+ I7 D" p) w( V - final int newLight = convertLight(6);
* e9 |4 d% j' @% s( W7 ? - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));' e* ^. V5 {! f2 T. Y
- final float lineHeightSmall = (y2 - y1);
, I% x6 U, L E3 E5 o, W - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);5 j$ b. ^9 W' H' i
- pose.popPose();( j: H7 P% P ~4 Q4 z( T
- }
) v4 E. }5 L8 j$ @
8 `/ R; w4 m- t- S- ^; {- private RenderType getLayers(String texture, int light) {" \4 t1 O0 M) t4 [% ~
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
9 G$ s, o1 [) } - }1 H; I0 M& {+ J
- 5 I W6 z+ a4 c$ {. R
- private RenderType getLightTexture(ResourceLocation texture) {
4 ^+ o* H. W; J& J; D+ C' R - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);- B6 |. W2 E$ x7 O- r3 o0 t9 r
- }+ g& L; `" I E0 l& b" B( X7 @7 B
! s- f: }7 f/ D& H& I- private RenderType getTexture(ResourceLocation texture) {
/ W: j) z' q8 I - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
) j8 F5 U; |/ _( n; {% ? - }7 J) ?7 q. Z9 m+ t# d
- n$ G' _1 V, ^1 R) w E- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
; g+ m. e/ A5 s3 ~' v - if (cache.containsKey(identifier)) {. Z: A3 A+ {$ G0 O# \. [. H) h, I+ l
- return cache.get(identifier);. \' Q& Y. {9 Z" p* {
- } else {
. k' C9 \; H5 V! }9 X: `2 W0 b - final RenderType renderLayer = supplier.get();7 k0 o' B O4 j" N2 Y7 h
- cache.put(identifier, renderLayer);
/ w/ s# p$ ]' _2 _ - return renderLayer;
( _4 W2 D. c l9 g% P - }
( P0 V7 C$ B# ], z | - }, E0 h7 x0 r6 v7 V+ E% H
- }
复制代码 |
|