|
|
# ?" p. a- v6 p0 ]行,这个怎么样
4 P1 j( W+ f4 { g, S- package com.xhg78999.mtrfac.render;
' \0 K0 T0 Q7 @6 Z; ]: U - ( u4 G/ Q7 ^/ i! h
- import com.mojang.blaze3d.vertex.PoseStack;
1 q+ g6 K$ r' E6 T - import com.mojang.blaze3d.vertex.VertexConsumer;
+ ?6 E7 a9 ~/ O$ ^7 S6 W- y9 q - import net.minecraft.client.renderer.RenderType;% s" l6 Z, q R: O" S0 Q9 f# j& i. }
- import net.minecraft.resources.ResourceLocation;% d& K: f: y2 g# T3 @
- + O% W' T; a6 s" U
- import java.util.*;
9 U6 h4 ]) Z/ f+ Z - : Y0 W( C( b ?
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(" k; q& A9 g8 f2 Y; @7 t
- / _ q) j3 C8 f4 J" i
- public class LineRender{
! C I8 [6 A5 p% ^4 w1 ] z2 ? - private final PoseStack pose;9 V1 r5 y% |4 r, X
- private final MultiBufferSource source;
- B8 V* c2 I4 g2 q" P: H3 { - private static final Map<String, RenderType> CACHE_A = new HashMap<>();2 Y6 r3 v0 y5 j$ Z% r3 \
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
6 g( ]9 R) {8 t; U9 E - 0 B& T$ `5 L9 t
- . a' a! G6 e8 f! G
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
- y3 `/ @# x/ v; e# }8 Y2 M - if(x1 == x2 && y1 == y2 && z1 == z2){4 Y: |9 G& z- @; x; [- D) p
- return;
5 `) K( Y0 i# }! ~( G - }
* v" ~- u" }2 o - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
8 V* G8 ]7 k+ V - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");1 [. ^. a% b, S- _/ B- X& h8 _
- }/ s/ U' n7 I7 L
- pose.pushPose();
9 r8 n% }* v! ~, A - final int newLight = convertLight(6);# z4 N* d5 y8 m
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
, C( s: \0 z1 Z& e9 o7 n' I - final float lineHeightSmall = (y2 - y1);
! _( b9 F: c7 m5 k3 m - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
+ y& ]4 d. G8 C/ c% @: a - pose.popPose();2 c" _9 O5 }3 I2 e& `" T
- }: C7 Y7 o' ]5 l3 x0 `9 @1 n
, |/ A# z7 x2 n8 d% d- private RenderType getLayers(String texture, int light) {) G# _7 y8 J3 h" b
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
/ U; E5 P2 @9 g9 N& c9 T - }
$ }( Z; b& x% k u6 j; F' o9 i
/ ~+ r) y% C4 ]: X1 h- private RenderType getLightTexture(ResourceLocation texture) {' D! J3 x r8 z5 E1 J7 }+ O+ Y
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
( o. [' V6 {) N& Z- ^5 ` - }
( F, E7 S$ }( }( u6 O) A& b - 0 R7 s! Y$ N: a* p0 B* I4 W3 `
- private RenderType getTexture(ResourceLocation texture) {
* i3 U7 C. y4 ?* W/ a- z* r - return this.cache(texture, () -> entityCutout(texture), CACHE_B);, Y( t! o- g& K' e" E$ m
- }
, N/ x; I/ \& M8 b3 h- D
. x, ?* k* o; o" q+ f3 O* b- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {( P& Y6 |2 s8 ~: r3 G3 y
- if (cache.containsKey(identifier)) {
2 ]* D+ b: p- `# X0 G - return cache.get(identifier);
4 d( q) p. t5 p( r! I! T+ ] - } else {8 `5 F& i' i3 }( c! p: r; l
- final RenderType renderLayer = supplier.get();
" T6 U1 c0 W0 W3 F - cache.put(identifier, renderLayer);( E5 w3 |) H7 h5 _
- return renderLayer;
! ^# C+ V5 E- g - }4 @+ M4 q8 G* ~ n; O- Q
- }
, O7 U& u! r' l5 B5 k' B" A - }
复制代码 |
|