|
|
: ]# u5 T# o$ I+ e9 L' Y- v k
行,这个怎么样
- ?3 H& I7 j; A- package com.xhg78999.mtrfac.render;4 L0 V) ^6 ?+ m' d3 p, l; D* V
- + y, |/ {7 ` ~2 d7 p! [8 s, S
- import com.mojang.blaze3d.vertex.PoseStack;: Y, n. J# ]* [* O$ V; J
- import com.mojang.blaze3d.vertex.VertexConsumer;
* U$ z* b! g2 u( x0 \! j8 N - import net.minecraft.client.renderer.RenderType;
; M$ I; v6 M6 e' { - import net.minecraft.resources.ResourceLocation;
4 u) y8 G) p- a5 u - # y5 _* r& V' u! v2 F
- import java.util.*;) R! {: m+ [7 J7 ?% z
0 n) Y8 f. m8 ?. T7 X2 j- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
7 A5 P7 I) t: P
7 `: S9 w8 a3 F$ O- public class LineRender{" z: Y" G+ r) U% p. T% T+ C7 }; I
- private final PoseStack pose; f. P& S! a+ i% e9 y( c& R
- private final MultiBufferSource source;4 ?7 R/ S& m/ m7 V8 L, O1 |
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();( ?& \- V4 f7 @/ c
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();; s( M, D5 P" W8 p/ m
9 w- ^' m- ]" O5 j: L- # _- T; Y4 Y( b, ]( {
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){% k, Q/ b- I# _0 ], `3 J2 L' }
- if(x1 == x2 && y1 == y2 && z1 == z2){
+ r+ u. G$ K" ^, b# G& u/ L9 l; {6 R/ s - return;7 U }* s7 @9 L: |
- }* D* M- }+ z8 {" m) p+ D0 h+ G8 W
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
& T( |' H g7 N( \3 G. _ - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");- |' _" E# R0 Z
- }# W# L/ n' L3 l6 C% D" A4 |5 n. G- C
- pose.pushPose();
2 t3 [9 S5 D" |3 L& P' j* W" h - final int newLight = convertLight(6);. E$ s2 P/ H* ~, j4 W
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
8 k- Y2 e6 k! u2 ^) Z - final float lineHeightSmall = (y2 - y1);
5 N" y0 _% Z& z5 t; e; Y. |$ p - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);# \( w- E( V X9 o
- pose.popPose();, x8 c5 X( q C0 J! `) p. Z
- }" @& q2 T* a8 Q7 c5 C- m2 K
+ P6 {/ |& P# G% u; S4 ^) h- private RenderType getLayers(String texture, int light) {8 Z/ k; a! e9 A* Y: Z2 `" q& }$ W2 P
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));6 v0 r/ A. V* q5 v
- }
: Y: K6 _) C% F$ X% ?6 z1 i
2 \* h5 {8 b, I) H+ ?- private RenderType getLightTexture(ResourceLocation texture) {( {8 d2 U, O4 x
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);+ D2 B9 d; A; ], t
- }
! U0 j) L! P% f$ R7 U$ E
9 n+ d& ]: f% C1 ]! O$ x- private RenderType getTexture(ResourceLocation texture) {( L+ K$ z) ^' n5 a
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);' I! D. o) K0 `. y4 L8 A
- }4 B. g* x! |$ ?+ v- [
/ r$ ^6 q9 j% Q; L3 M- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
' x) I5 i8 w. O4 s8 v6 d, Q* V - if (cache.containsKey(identifier)) {
& q/ q( z; e6 w. ~7 b8 q* g - return cache.get(identifier);
3 l9 w7 a: I0 a1 y" d5 {, H - } else {2 h* V. {) G% T2 j2 Z) }% p
- final RenderType renderLayer = supplier.get();; d" u$ L1 J1 I
- cache.put(identifier, renderLayer);
2 x5 ?1 Y1 _( o* r8 g - return renderLayer;" N! Q! R: E' Q0 i: R7 K
- }) O- \$ c/ `# R* X' n
- }) i# b' X) P4 Z' w$ }
- }
复制代码 |
|