|
|
3 \+ X2 {$ A" c# i. e
行,这个怎么样
9 U2 g7 r9 R( w- package com.xhg78999.mtrfac.render;
8 i$ f- m6 k+ L, U - / K+ {0 c4 c+ Q) e) e- L' o" n$ M5 Q! E
- import com.mojang.blaze3d.vertex.PoseStack;# J$ S7 {( c u& K- H0 Y
- import com.mojang.blaze3d.vertex.VertexConsumer;
! n. c. `: P {) D8 I - import net.minecraft.client.renderer.RenderType;2 h' }3 ~" f" F" ]7 R- F- ]3 [
- import net.minecraft.resources.ResourceLocation;0 E& `* N& G" E, k$ n R* Q
- 4 D1 y7 d( k, B1 M5 o) e6 h( z
- import java.util.*;3 R2 c0 f+ V+ W4 U
- + |. l0 P# |6 T9 K
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(' b/ L0 V% a2 A! v/ l4 o& `2 ~- `
- ! [7 a- E8 i+ s( q' r* n; q4 @% G8 k
- public class LineRender{& J& h8 d E4 ?3 N8 g; Z- c, m+ ?3 E3 Z
- private final PoseStack pose;/ r& f5 p: t$ t- h! @
- private final MultiBufferSource source;
% A3 Q( h! r3 ^$ D# q! Y% z - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
8 w9 p0 Y6 l" W/ Y { P7 }1 h7 U- C - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
6 d- D! D0 b1 d/ t& [0 m5 H - 9 @, Q! l$ @/ v j/ l
- ! V- K% n7 r7 c
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){' j8 r) e0 |" Q: _) M1 g
- if(x1 == x2 && y1 == y2 && z1 == z2){
: Y2 Y' O% f9 N - return;
0 S- r1 J- |5 W- O - }
" i6 I* Y/ S! c! t1 b M - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
: t' g1 N1 ?8 Z Z9 M0 Q: Q+ y - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
% |" i; u7 l! B9 R$ i - }" D& \4 u |2 n+ o
- pose.pushPose();
- e/ ^, n7 k8 Q7 |, ] - final int newLight = convertLight(6);! p6 s C+ b. q) ~2 o$ Z
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));# s" d' C6 S! T. s# F
- final float lineHeightSmall = (y2 - y1);
( R" p/ q& r& H7 j) g8 } - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight); a; H+ k o7 N1 {' f5 p! Y& B; \
- pose.popPose();
1 R! K. V7 Q& u) f - }& G+ R% ?1 r9 T/ e3 B+ d
- V4 h7 B. m t) `8 [. r& G) K- private RenderType getLayers(String texture, int light) { L; T( [; S) j) i# f% y
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
) l9 E7 |& ]0 b" i! o7 ^ - }
# M% x8 Z# A) P
7 F, v% T2 f$ K; a7 [7 |8 R, Q- private RenderType getLightTexture(ResourceLocation texture) {
* x0 c4 N- X/ W" z6 m2 w: c2 @ - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
+ B# ]4 F. P4 b0 D. {2 @8 r - }
, W. G5 I0 u+ B# ^+ d& w5 p - 6 }+ ~5 {: L8 o3 T( H3 u
- private RenderType getTexture(ResourceLocation texture) {
# ~+ e8 S- p0 Q% y - return this.cache(texture, () -> entityCutout(texture), CACHE_B);: L: R+ ?, |$ K) v
- }3 \1 x/ n3 D4 j" S
S: ^7 C, F6 w# G- c- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {) d6 d3 t$ G* y4 o' P
- if (cache.containsKey(identifier)) { _' O1 f9 a* R. o
- return cache.get(identifier);5 x7 _7 ^ P. t2 s# u
- } else {3 j( _7 t% W4 I9 z, T
- final RenderType renderLayer = supplier.get();, t1 H3 g/ a& _( |, e
- cache.put(identifier, renderLayer);& C' C* l' { [5 O/ s
- return renderLayer;
@2 x9 `) t8 G! F1 r/ \0 r - }3 e% G+ I7 v0 J9 A
- }
7 V2 m2 Z ~! {* e - }
复制代码 |
|