|
|
# X. c& Z+ b) U# t
行,这个怎么样
& e5 q3 `9 j2 d; i, I- package com.xhg78999.mtrfac.render;
* ^( Q% U7 C/ i: O# S6 P7 b- v - % _" G. P, V+ i( M5 Q5 @" Z0 j3 {
- import com.mojang.blaze3d.vertex.PoseStack;. z" h0 I0 Q5 V9 X% p) S% o" K
- import com.mojang.blaze3d.vertex.VertexConsumer;
- r, l1 {. k) M( f" x - import net.minecraft.client.renderer.RenderType;
2 z0 T8 k% f) D - import net.minecraft.resources.ResourceLocation;
0 D) K1 d% r) F7 H% g x+ c; g
- R2 a4 f# l" x0 b- import java.util.*;
. a4 x Q5 B9 A t9 H
, L: R+ u& o) \. I- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :( M/ Z3 J7 \7 M$ o
{0 y$ t9 l* @1 s) }0 X* m# s- public class LineRender{: q# _1 G( }, J$ g8 q: ?2 q0 p
- private final PoseStack pose;. E% B; v* }. U2 U( [
- private final MultiBufferSource source;
6 _# M6 v) R' t7 q' v - private static final Map<String, RenderType> CACHE_A = new HashMap<>(); O3 S& V, t( O
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();$ Z9 o0 G+ t3 y: }7 K
- C' f& e. _9 ]# ]& T: ^
+ q; P4 f( j' G5 A# o- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){ n( K3 U, e- J7 C: | c& r1 w) O
- if(x1 == x2 && y1 == y2 && z1 == z2){
. X# f+ q. @1 m" b; } - return;
$ Z& [$ g) R4 E# x - }
; n% _/ p0 p) |5 j" n7 o - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
3 _& }- F9 q' e7 @4 f - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");/ r- T' r7 g1 s& _* f3 V3 L: ^% Y# B
- }) F4 q. L1 p9 |! e I; X2 K. ?
- pose.pushPose();; ]6 x" k& Z' f
- final int newLight = convertLight(6);: M' v1 L5 c1 d* O. R( Z- C
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
7 N. e% m2 i7 Q+ u6 B0 r( P/ ] - final float lineHeightSmall = (y2 - y1);, C. T6 @4 ~1 w' S6 v. n3 s' ?7 u
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);0 r) e. B, @' N6 x
- pose.popPose();1 V7 v2 ^7 V! F0 M5 A; k- s
- }0 c8 N. I6 `% A9 B% y8 J
- # [, }/ G' m8 h; J, A/ U
- private RenderType getLayers(String texture, int light) {" N* x9 M! U0 n4 z- ^
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
+ I( E# T. [! \4 O! I5 L4 v - }, j7 E# e8 o0 I5 B- p+ ^
- + V7 ?# a1 \6 ]; o
- private RenderType getLightTexture(ResourceLocation texture) {
' I$ g8 d- {+ }/ }5 i0 \( O - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
8 f- q9 Z5 @+ a+ `5 T - }
7 z" A/ s7 r4 P- Q4 J6 r& B! M
! f" A6 D( Y! I1 z7 F- private RenderType getTexture(ResourceLocation texture) {: O5 {. u I% ^, y6 E
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
0 g, o: t' r) d6 T ` - }) ?+ V3 s* ]5 y4 B6 l7 y5 v7 |
$ ]' S8 s' Y* E. }- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
) E, A, N6 i6 C+ Y) _& S - if (cache.containsKey(identifier)) {3 [ ?6 b0 w- c% g% }) r1 @0 }
- return cache.get(identifier);
! D1 B& t$ c$ R, E4 ~, {) [ - } else {3 v& d6 d' y# `1 b. Z' r! i
- final RenderType renderLayer = supplier.get();
9 o) t+ q6 S* u6 A - cache.put(identifier, renderLayer);) p- ^- w) {6 c7 D! Y: o6 V* o
- return renderLayer;. u2 o2 b q+ x$ V2 f" b
- }
* }! \. h" z/ l4 l, L2 E: W7 e' c - }. F4 _6 {2 W9 J+ s D
- }
复制代码 |
|