|
|
* D9 A% d7 C5 K5 F行,这个怎么样
$ I8 R) z) H$ K$ v% l- package com.xhg78999.mtrfac.render;' x* o' A8 n3 m
5 C; m3 a0 ^5 g# C& Q- import com.mojang.blaze3d.vertex.PoseStack;
x) \' o7 \/ d/ n8 \: G - import com.mojang.blaze3d.vertex.VertexConsumer;
) a2 ~$ t& k. y$ G1 e. D) m - import net.minecraft.client.renderer.RenderType;/ A) B: q' C, g/ D' R# C) O7 d- S/ \
- import net.minecraft.resources.ResourceLocation;2 W5 ?9 J5 p* c; f! k. I
- 5 b4 R c D$ E2 S' S
- import java.util.*;
6 f# X7 t' u/ r, i - * C5 j E4 r8 Z2 `3 J" [
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(" R& } w% n# u V$ X( i! {
- / X' _* p/ g4 }& @
- public class LineRender{; J: N' a* t) }9 c
- private final PoseStack pose;
2 w4 r: k$ H7 ?: ?0 K* J e - private final MultiBufferSource source;: N4 Z8 q9 q- X! J. E' V
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();; Y3 e" |- a+ P- `- @, y
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();4 G+ X8 e* {4 q
" T C% O6 Q, r- w1 ~! K
8 d) `4 V; W. x2 x; Z% Q- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){( z) B0 H! n6 `
- if(x1 == x2 && y1 == y2 && z1 == z2){
: V7 z. K7 i! Q ?1 u" Z5 I - return;
" J t$ ?' H0 u+ b0 X5 p) c - }
2 G8 \' H; U+ @0 H( D - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
0 |# X4 ?! m$ Z" { - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
|5 ~3 E+ _) X4 s - }
% [3 `5 V/ e( {" `6 O - pose.pushPose();# L% s8 {! x/ ?% S8 y
- final int newLight = convertLight(6);: [. N7 w6 j" H8 n6 K/ E `8 |
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
! G; s4 A; M& i( R# W# J9 G - final float lineHeightSmall = (y2 - y1);
2 T0 v5 F9 ]2 F- J - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight); Z; v, @$ k/ v0 v6 p9 [/ i
- pose.popPose();
, B) ~1 K+ S8 f+ {" U$ M - }
5 W" ^' ~$ k7 S" ~/ _ - , {$ U9 C$ M% ]/ ^* D$ j7 y
- private RenderType getLayers(String texture, int light) {
% N# C; `% L, U* U; j5 \: V& I - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));+ i( w) ^/ H: x' t$ {
- }
3 h4 W! P* V O - 6 O7 A/ _; _0 k8 K
- private RenderType getLightTexture(ResourceLocation texture) {
. Z4 q" L8 q- L - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
" ~( b3 G$ a$ l9 y - }
6 v3 Q. F2 H" y+ @ U( @! b - 9 D; `, w0 V8 h) d2 G
- private RenderType getTexture(ResourceLocation texture) {9 }% x: A% t( \$ U
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);( j, d) N% x) X# {
- }9 D. k# K9 }, w9 V* k- c1 R
6 U: t# ^: J5 w! |# J- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {5 \2 _, K0 w6 T; M+ E
- if (cache.containsKey(identifier)) {) F$ z# h7 F* b' y( j2 c
- return cache.get(identifier);/ i+ `' S: {+ u/ H$ F% ]
- } else {
8 ]5 ]7 `4 U7 b4 x. a - final RenderType renderLayer = supplier.get();* w6 s9 x4 F: x2 B
- cache.put(identifier, renderLayer);6 p2 M/ p z% ]* y1 V9 F
- return renderLayer;
$ z! _% \3 _3 x6 x5 N8 X - }
5 ^: ]9 |% P8 a% J6 W) @0 E - }0 H) M% Y! ?$ u7 M, `
- }
复制代码 |
|