|
|
! @, m# t1 g+ A$ ?行,这个怎么样
1 G& ]: h1 K1 u5 Q0 q( W- package com.xhg78999.mtrfac.render;3 Q4 g; u; O4 z1 d8 x# ^& e
- 3 ?% a$ u- n% P ]; i
- import com.mojang.blaze3d.vertex.PoseStack;
9 t1 a4 D+ U5 P0 w# @- { - import com.mojang.blaze3d.vertex.VertexConsumer;
7 s! l5 W5 s# r& \9 ~ E$ h+ n/ O - import net.minecraft.client.renderer.RenderType;3 A7 w* H3 _/ f B% l6 J2 X
- import net.minecraft.resources.ResourceLocation; e; u" m" f+ {6 w3 A" D0 h
- & @5 I- _/ c& m- {* O& ~
- import java.util.*;
" C9 X1 e* R& q- ?' C! K - - B4 K. ]' C# u7 ~
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(- R$ j5 b2 w4 |1 c
- # V+ ^. b' [; ^4 I5 z! R* ~& [
- public class LineRender{
% E5 Z8 |& t/ y: w1 [* J - private final PoseStack pose;% f7 V3 ^* y: Y9 w0 i% z) \
- private final MultiBufferSource source;
4 S d1 s; G8 N! V- g3 J - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
5 V! {( i+ V! s - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();+ P- E# x! t" I1 v
3 r$ s1 d; [6 Q9 v- ' Q* _0 z4 i6 M \! V: E
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
& j# B7 Z& q2 F - if(x1 == x2 && y1 == y2 && z1 == z2){' v6 Q) k* E o; F" f
- return;
9 Z9 N$ `% M& P9 m8 g/ ~; R V, L - }
3 Y% j7 U7 a5 m - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){' i9 o2 ^: J0 _
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");, j( M t9 a/ t: [7 B
- }
1 G9 e8 i9 n4 P- m3 P! O - pose.pushPose();
! u4 x' E; E6 h. \+ `! z, K - final int newLight = convertLight(6);/ A0 f4 U. m. W: y
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
5 R# ~" k1 f& H/ l - final float lineHeightSmall = (y2 - y1);3 l I/ {* l3 D: L
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);" e+ I, Z' S) _3 `1 P3 l! K
- pose.popPose();) p! B5 n; Q5 U3 l7 \$ V
- }5 F4 d! J4 R8 ?) I9 v+ j) Q( J" A
- % J7 N, o1 s3 H, a8 o
- private RenderType getLayers(String texture, int light) {; w* O; D3 v5 v. F% W9 D& s6 r
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));) Z- h$ t- _1 t
- }3 W" x( a* N% T3 I) j
+ `* n! l0 o. s y; u: o* T- private RenderType getLightTexture(ResourceLocation texture) {& B6 Q2 X+ e2 ]- l. P+ K8 D
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);: _3 V$ |8 c0 S9 l
- }8 I5 W2 Z. q% k1 ^
' h: |2 E, D. c: `1 |; n- private RenderType getTexture(ResourceLocation texture) {
) ?- W3 b9 i9 k+ ~3 W5 ? - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
$ U$ Y* l, y C. k7 J D& N - }
5 ~8 r3 y# R$ @ - , ?+ c5 b `3 O; u! U/ w+ p
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
2 O, L2 D7 x# h, m: ~$ \ - if (cache.containsKey(identifier)) {
3 f- ?! D6 k4 j% g7 O$ X1 I6 x - return cache.get(identifier);0 D6 a$ k) H2 y3 @% i2 w, X7 Y
- } else {
: c5 N) a" D4 r G5 t$ J* g" ]4 n J - final RenderType renderLayer = supplier.get();7 _# i/ r; W- b
- cache.put(identifier, renderLayer); g! h0 K7 P9 W8 N* k7 o' x4 B7 o
- return renderLayer;. S8 u5 i- J- U
- }
4 D2 z* F2 v4 r/ P - }
# k, z. `" Y" Q5 A5 [ - }
复制代码 |
|