|
|
. ?" C9 U; i; }. R
行,这个怎么样
9 }- a, d5 l1 T6 d- package com.xhg78999.mtrfac.render;
9 `' t3 H2 b7 g- s4 x
# {, ^1 @1 w4 I; }/ n! O( n- import com.mojang.blaze3d.vertex.PoseStack;1 v) ^, p t( G& x
- import com.mojang.blaze3d.vertex.VertexConsumer;
! Q1 e1 @$ |5 T O - import net.minecraft.client.renderer.RenderType;" @' z- v& Q( G$ j
- import net.minecraft.resources.ResourceLocation;- _8 y& e! [5 t) h2 ~
- 0 [/ @, j1 m( h
- import java.util.*;
! n* y2 [ M2 G) E+ y - ]+ M e1 \/ T Z
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
0 N) q' i2 t# a( E6 q8 i - " f, V0 S& a; z9 y1 H
- public class LineRender{
3 c% u, Z3 y5 x! i - private final PoseStack pose;3 o; x* d% s s( ~
- private final MultiBufferSource source;
% ?" {7 x3 |. b9 Y - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
, a4 W. ^* m5 x, V' b - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();$ ^; `2 D* s& M. E
4 P* p7 i8 A6 Z- 3 ]/ z6 d @; D9 M( L/ k3 h
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
: z! Y8 X4 d: q; s |- L# A/ d - if(x1 == x2 && y1 == y2 && z1 == z2){
. q. P' y* m+ M - return;( K8 x8 V P2 x# q) a0 j
- }7 I4 S' m9 Q7 j& F7 N( e( c" A
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){* Y+ y ]- M W5 }8 g2 s
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
# E- t3 W. P7 E - }
& M3 f7 |; v0 p4 M o5 X- o. ? - pose.pushPose();
' c' w w; u' i - final int newLight = convertLight(6); ?) N! ?. y8 s# v g* W7 A) h
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));" U$ w6 U- d, k" R
- final float lineHeightSmall = (y2 - y1);+ ?) ^5 ^" p, A9 }. L0 L9 Q* [
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);' G/ A& C1 C' O) s( ]7 I* V, u) l( u
- pose.popPose();1 Y0 F- Y5 b- }$ U: w4 B- S& ?- O
- }
' z7 a" ]3 C" F. {5 M
: Y' ?9 \. G( J* R- private RenderType getLayers(String texture, int light) {
3 r, K; v j4 z) g - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
9 O6 u. b& I( A+ k$ }+ W - }5 Q- e) `7 \, J; ]8 m: B0 z
( C9 s7 D; |& m. z) t0 [+ [- private RenderType getLightTexture(ResourceLocation texture) {# K& ?% u! h5 D2 s- u9 ~
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
+ L6 r$ k8 f$ X/ L - }2 B' W' C5 A" M
- # G, D9 j1 H0 d: a* n! H2 y
- private RenderType getTexture(ResourceLocation texture) {
# N# i$ h, _ t- C8 }+ z - return this.cache(texture, () -> entityCutout(texture), CACHE_B);) A. y% }" F0 W" M' ~! d: r
- }' K: M9 F1 {$ m
- " v9 E( s6 m1 W/ m
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {3 s4 x' Z3 k6 G/ b x2 Z
- if (cache.containsKey(identifier)) {$ r/ q) M, h1 p; L) X+ X/ n2 k
- return cache.get(identifier);! N& w* a+ e# d4 O
- } else { N' l% X F4 O
- final RenderType renderLayer = supplier.get();2 A2 ^& W0 q# F) k2 Y j7 d0 s5 H' B
- cache.put(identifier, renderLayer);
- g3 F; S+ s6 e7 |$ G6 q' r: m1 I - return renderLayer;
C( Q: U5 w8 _& D2 N9 o - }
/ ]3 c6 ^4 Z8 d - }
1 ~! _1 e8 Z3 F - }
复制代码 |
|