|
|
' [/ f! b0 h+ F
行,这个怎么样
* a8 p+ B6 g; C+ g* P1 c1 @- package com.xhg78999.mtrfac.render;, C: i8 R1 [& x) ]7 G1 F
- + [( b# q8 j3 I7 b6 N" E- S8 q9 j6 W
- import com.mojang.blaze3d.vertex.PoseStack;1 h6 C* V! k& ^( `* T/ f
- import com.mojang.blaze3d.vertex.VertexConsumer;
' Z( C5 x6 s$ i - import net.minecraft.client.renderer.RenderType;
+ F7 L# J/ m9 t; Y5 ` - import net.minecraft.resources.ResourceLocation;* {7 Z. K6 L* n" ~7 R$ \4 `
- 5 ]7 ] e! S' I- O5 }
- import java.util.*;
5 L+ ?- a- ]; b
' W; h" N$ k! S3 c$ B- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
' h9 l4 ^4 \8 T3 V- I ], z8 ? - : q5 E: R5 H3 l; a
- public class LineRender{
7 y% o7 U, D% [* t' H; K* B0 N - private final PoseStack pose;
9 s2 ^* W# |1 M! ?" d - private final MultiBufferSource source;
" R' M6 ~' o, V - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
; A6 u/ p! y5 t; } - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();0 w7 g" j8 V2 X1 I Y" l! q6 s
: B: Y/ J {) y1 @" W7 I, |* Q6 [
% E6 f: B/ \" H- E- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
% ]# \! ^4 C. c7 b) z9 d - if(x1 == x2 && y1 == y2 && z1 == z2){' t; `/ L- j3 i9 P( u9 Z0 K
- return;4 H' |8 ?0 b$ w% E. A* F
- }
. t+ o! ^ c- y, x - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){9 I8 W) o1 H, z1 M* D J
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
8 r5 u; j4 D1 \6 y - }1 P, {. A( s2 K1 u
- pose.pushPose();
5 n t1 o! y! @. ?5 J% o7 G6 e7 j - final int newLight = convertLight(6);7 x6 @3 f3 W, [6 v* z9 E
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));4 G4 ~* V. K. {" o" ^: B
- final float lineHeightSmall = (y2 - y1);
: u. d" H ~5 V5 t( H, i - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
, A8 J1 o+ a0 A- w g - pose.popPose();
( _" ?( t4 `4 A# R - }$ _# x+ m9 M9 M w7 H0 e
- . y7 X# M$ q4 m M( A
- private RenderType getLayers(String texture, int light) {) J, B& c. ?+ W* x. d) s
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));, u1 F) V$ A% M0 m
- }
" z+ u; @, d' b" X - . Z: R0 k( h+ }% ?& R: l
- private RenderType getLightTexture(ResourceLocation texture) {
% O7 Y. D" ]; i9 A2 I; E$ U - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);. z! M& A" i; Q7 } ~
- }
9 _0 V) D& |* h& k% S# n - 3 J" e5 s3 E, V9 u, Z, X) e
- private RenderType getTexture(ResourceLocation texture) {9 f4 @1 [. c2 P5 U" D
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
j( K1 H$ ^: A6 D8 @ - }
; }3 S- |3 e2 K2 S9 {; H' g - % m; U# H; A) ~' v# J
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
. q" U6 V% R! E0 b9 X/ } - if (cache.containsKey(identifier)) {. `* r- ~ |& d4 ~# F
- return cache.get(identifier);
* A( C5 B9 s9 T$ g+ j2 } - } else {
' T$ d# N; E1 }* d2 B - final RenderType renderLayer = supplier.get();
( ^' a* Z- S) k- q# P9 @# l9 o) Z - cache.put(identifier, renderLayer);
}0 P0 d8 }0 T/ z# G3 P2 S0 w m+ L - return renderLayer;: U4 G) ]4 b7 r+ @. p5 H, H( x0 g
- }$ c) p1 r, u. u% o. B$ [
- } l3 b" R0 @9 S
- }
复制代码 |
|