|
|
8 q8 v% ] [& M) O8 M. G
行,这个怎么样
2 X q4 q `' P9 V- package com.xhg78999.mtrfac.render;
) F1 d H* U9 A; l, L
8 V! ~! m3 i/ w! G8 N+ Q- import com.mojang.blaze3d.vertex.PoseStack;
6 z T5 z% Y6 s8 E2 g5 p: ` - import com.mojang.blaze3d.vertex.VertexConsumer;
7 S( y) p( L- k" {8 n" j7 c - import net.minecraft.client.renderer.RenderType;
5 f; _9 p1 }6 m8 E' o; y: @ - import net.minecraft.resources.ResourceLocation;
1 v1 p* h, F9 C1 K5 e5 _ - ; B- i. ]* ~# S9 [0 k
- import java.util.*;
; a" |4 p) o; C, F6 W- v - 6 ]1 {* o8 n- s1 I$ U
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
+ t: I) Q4 i- P. [1 x3 {. o) F5 J
% y) X7 T0 T4 G) e1 q- public class LineRender{5 W4 p. w9 ?, G4 g& y
- private final PoseStack pose;9 _* G# l; M: h: b6 D5 m+ j8 P
- private final MultiBufferSource source;
8 u: n8 F( {; E - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
* v/ n3 b4 O, v2 O5 u1 G0 V - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();! `; x0 c8 J6 d
- 8 R* F1 Y7 J, H/ I
+ j. ?# p- v# d$ B: E9 q! j4 P- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){# I4 v/ U/ {! L w. @8 A6 j1 Y9 ^
- if(x1 == x2 && y1 == y2 && z1 == z2){
( C1 Y+ A1 J. h& ]( v; @ - return;! j, W/ l0 m4 G" ?" T
- }8 D2 x& _2 c1 o* D1 h' A
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){7 I6 T9 T, j* s! E+ k- j
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
+ H1 l# {$ K; T' U2 b& ` - }
; b/ k* C3 C9 C) ~2 R- R, t - pose.pushPose();# V9 w6 O9 S' e# I* d& U1 n; S
- final int newLight = convertLight(6);; i, H4 n7 ]2 l
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
$ |) E% P- E e& F - final float lineHeightSmall = (y2 - y1);
+ g: K: Q; m9 u% Z* n - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);$ a' y0 B9 Q+ @7 y/ Y3 s: O! N6 X
- pose.popPose();% b/ t3 H+ A; ~, |3 j
- }
, c/ m/ _* }' ^9 l* @' I2 e - ) l0 f0 K+ i. H& j4 I* K
- private RenderType getLayers(String texture, int light) {
3 J7 O( R) B U" s, O& m9 ` - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));( g5 \2 G- c9 o3 a* w! V$ n) L
- }
3 k/ H j. I* b' [- G% |+ u
% s, G C8 i# s7 f3 m$ n. U( g- private RenderType getLightTexture(ResourceLocation texture) { i9 ~ X* W4 g9 E
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);" o/ N' a& {7 ^. L
- }$ b0 ^( B! l! D7 \7 p) u" H1 O
+ H' E1 j% {8 n. I- private RenderType getTexture(ResourceLocation texture) {( J. w5 m0 P8 \. V
- return this.cache(texture, () -> entityCutout(texture), CACHE_B); l7 ^/ ?" |9 Z/ f) {
- }
1 z$ h l& R% Q
8 \4 Q; G$ A+ K9 M; u- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {0 b2 F* g, W& k3 a% U7 _, @
- if (cache.containsKey(identifier)) {' M/ J0 S8 ~0 e9 t- N
- return cache.get(identifier);+ { j$ b- A1 c0 P
- } else {% |0 p; q" T# K1 l; z/ D, ]& q
- final RenderType renderLayer = supplier.get();
1 q4 J7 y. _- l6 ? - cache.put(identifier, renderLayer);. N. \$ ^) m7 O8 J0 b
- return renderLayer;
$ D3 t9 V" q! x6 Q5 n - }' |& D" h- F3 W; L2 T, @7 Q6 R% u
- }
4 M* [( c4 ?0 ?8 | - }
复制代码 |
|