|
|
2 L. o0 g% P- g! p2 ~8 J
行,这个怎么样
) b, H' c* K& {" F; f2 `; `- package com.xhg78999.mtrfac.render;% X# o" |/ S( n/ r6 ?. e
- 5 j5 A$ l" w" j3 M! `
- import com.mojang.blaze3d.vertex.PoseStack;
* J* E6 B8 k# N5 o# S0 h9 e1 g - import com.mojang.blaze3d.vertex.VertexConsumer;: E o0 s$ N1 L# a
- import net.minecraft.client.renderer.RenderType;& M, u4 L" q. l. p; [
- import net.minecraft.resources.ResourceLocation;
3 s* w& Z: Y6 M( W" B4 P N - , e$ h: H2 j' p+ q* N8 Y
- import java.util.*;
! ~) s- D Q' q8 K( f
9 _) Y8 c" @/ m9 T- @- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(" q/ N( h& T$ ~& N, N
- 0 B" g9 z+ ~+ |, o
- public class LineRender{
3 a+ v4 B4 Q: c0 \; f - private final PoseStack pose;
5 x2 L$ n$ O* O* \" E- e! N/ x - private final MultiBufferSource source;
2 r/ M- J8 q5 @2 r5 u5 G - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
6 R y+ O5 ]0 K; d' _% t4 W- m) e - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
% ~: q5 T* d3 H - ( w. j) `& v: }3 V
- 4 j! E/ \+ I7 h! t% p
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
+ k4 m- L* [, y8 w6 [5 J0 j: c - if(x1 == x2 && y1 == y2 && z1 == z2){
r' ~" E% B* i; P9 X. C& L - return;; S+ [! ?# M# k0 f8 o
- }" m' F7 q t) K# R( ^
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
) U# Y6 n. c) u5 K. r - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
' f! W5 `5 }5 K2 |& U9 y) h - }
; `' f3 w+ {1 q& H - pose.pushPose();, c8 \: E. W, q0 t+ q& q' W, G- V, l2 J1 p1 t
- final int newLight = convertLight(6);, ~' x% m. @( p" J$ i! ]
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));! d& [% G" z2 H: E$ `0 j0 a; U
- final float lineHeightSmall = (y2 - y1);
# e- a7 b& x: K+ [ t - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
6 [/ y" }$ ]2 R2 A% l1 n# c% @ - pose.popPose();, i6 A$ ]0 C$ z( k" o+ R
- }( Y b9 L: i' s
8 T- x/ P3 p4 T$ H5 o- private RenderType getLayers(String texture, int light) {
* F5 o8 Q2 K$ W; a/ C - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
. r- c. y* n. ?" |& s - }! Z4 D# l# g2 h: n$ N4 S
- 0 l' ]7 S' _- ~
- private RenderType getLightTexture(ResourceLocation texture) {0 e* ?. V A$ w9 {
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
4 P% C$ b9 B$ @: D/ G# p5 [ - }! P& m' J2 m) ]5 f7 u: b" c* H
- / j) T7 d$ o3 i% q; ^
- private RenderType getTexture(ResourceLocation texture) {! y* P. |6 o4 C6 z
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);- Z2 `1 u* n2 r! h( V
- }
4 O' L1 D) O, f
: F" D$ G3 D7 M7 A' E' X4 g- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {+ t0 C- W) t+ w6 M# P( n
- if (cache.containsKey(identifier)) {
3 F4 g0 W5 A# x. d - return cache.get(identifier);% @1 L9 p/ T/ K- t& H, h
- } else {4 G% |$ R+ V4 H( q
- final RenderType renderLayer = supplier.get();
3 i5 o& c1 T& @9 H. L5 e6 C" I - cache.put(identifier, renderLayer);
; W. V" [9 }0 o! ? - return renderLayer;7 C# p. k( |/ ]
- }
4 e7 `( }5 O6 n; @. p# } - }
* y* a* K* w. ?7 z% z f: w) h - }
复制代码 |
|