|
|
/ X4 b7 Y7 {8 x8 k' b: s1 c行,这个怎么样! H7 ?: s8 |: ]9 ^3 v
- package com.xhg78999.mtrfac.render;
- r% b; A& N: E2 R) t. O/ {& Y
# u7 N. s) O& p5 @ W- import com.mojang.blaze3d.vertex.PoseStack;9 X+ Q6 [6 T# o( {
- import com.mojang.blaze3d.vertex.VertexConsumer;
4 N# V2 q9 r' l; O - import net.minecraft.client.renderer.RenderType;% G# B2 r# _$ k& ^+ D: G
- import net.minecraft.resources.ResourceLocation;
0 j s# K- t/ J% {% g& V7 N
* _2 }; a" n8 s$ l- import java.util.*;
, r& x# h5 x+ N f. v3 w0 o. n - , a3 R h) z/ z9 ?% f
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(: h6 M. d; G$ E% I4 J3 L
7 W) s& ^9 V$ r1 }# k' V c5 g0 d- public class LineRender{3 P o; y" E2 V& H* s9 g
- private final PoseStack pose;
5 ~; X6 Z X+ q0 q- Q+ E - private final MultiBufferSource source;4 W6 A) p; P* c8 R3 R2 p+ `
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();7 C0 E* @5 L# G9 c; V4 A
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();. W1 |9 Y6 G5 q; }/ Y# @; e
' J" |8 y6 d' m: H- 1 H4 K) F- {. G- {8 Y0 T
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
3 ~2 ]' b0 {) T% i+ o - if(x1 == x2 && y1 == y2 && z1 == z2){
' d q/ d! L. B+ q1 k - return;6 o# t8 I8 q0 k8 x: u# q2 v
- }
1 V7 _$ N) N1 T! L+ A - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){+ B( E/ @' [# G; m. R
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
3 Z- ?) l8 ], D6 w# g" U0 J - }5 \! B) `$ [) w5 P$ R3 n
- pose.pushPose();
4 s; o+ y Z; G( y% S" \% F! f9 F - final int newLight = convertLight(6);; y1 Z: B) z0 l/ R( n2 A+ J
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
- m8 z. v1 k0 l' p/ J2 U - final float lineHeightSmall = (y2 - y1);
+ n6 ]& h5 f( }* l/ S8 W* K - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);% q5 T/ B: ~; a* I7 W* H
- pose.popPose();
/ o8 K4 `/ `# K4 T! A# a2 H - }& w# e8 d6 y8 o
- 5 c5 u$ A0 s7 N0 x9 n5 g! i
- private RenderType getLayers(String texture, int light) {
' }& x( J. V& } - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));. q* z" r) B$ @5 N3 \8 y0 P
- }- q( Q0 b$ Y: h& g* @# G
- : c# \0 B7 G# v, P: F% o
- private RenderType getLightTexture(ResourceLocation texture) {8 k- r! w1 J, d2 i* ?
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
+ A0 o F; L0 B2 v& S/ f" m7 } - }
) U& k. W( B/ a- k& L& z
# c4 w; {! \( C: A' e: ]/ h- private RenderType getTexture(ResourceLocation texture) {
6 j: _2 ]; }6 M7 F3 O) Q - return this.cache(texture, () -> entityCutout(texture), CACHE_B);0 Y- T0 L! e& w0 l/ W
- }/ M8 h8 H6 C3 ~2 l `4 e5 I. @
& h5 s0 ^5 i* E; H- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {* I, }$ ?! x# |9 c: K" J
- if (cache.containsKey(identifier)) {( F r: ^8 D1 W0 u1 `( r/ ]0 ]& j3 |
- return cache.get(identifier);
8 D4 q7 W% x& S- M0 D! @% l" K- q( U - } else {
' M2 R8 P+ ~5 v: t, ~# o - final RenderType renderLayer = supplier.get();. @" a' a6 l2 |- }, I' {
- cache.put(identifier, renderLayer);3 R- x4 Z4 d" q
- return renderLayer;9 c% ?. c' Y- H# G- S# G
- }
$ y1 b" d" w: T* E* [' v% Q5 y" R - }7 B. @8 L/ L7 w, u2 H! r# e$ q
- }
复制代码 |
|