|
|
: ]: E+ }+ S$ o# n" A3 `
行,这个怎么样
+ }- q( b$ i9 Z4 y- X- package com.xhg78999.mtrfac.render;, `% C7 \ x7 b) ~
& n( S8 s! `8 o" U- import com.mojang.blaze3d.vertex.PoseStack;. ?0 S: i" E' f. j4 V
- import com.mojang.blaze3d.vertex.VertexConsumer;
, C* ?% W' @" V/ L - import net.minecraft.client.renderer.RenderType;' ?3 f. o0 U; o& l" H
- import net.minecraft.resources.ResourceLocation; R/ [# Q! y. G0 s$ c
- 7 Z- X# ]- C5 f
- import java.util.*;
: m9 x0 I# D$ F3 x2 p1 T
4 \$ A- Y% R( U% t2 y- n4 y- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(+ C& ]9 C$ a' K2 R! s
- - [ e) ]2 Y* v. A5 M4 J+ @5 d' M
- public class LineRender{" K* S4 \9 }" T
- private final PoseStack pose;
& K* |2 y- S" k ]' I: b& }4 Z6 U# o - private final MultiBufferSource source;
, J3 p9 [8 n+ H - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
& U6 b8 Q. d* ?, I6 S( ^+ ~- }( z - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
" I7 {/ c C2 D7 } - ! f, Z9 N% U" S+ n. _" i& o
- . ]9 [: C4 t) n/ K, x
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){" q5 O4 l" p R; K" g, u
- if(x1 == x2 && y1 == y2 && z1 == z2){
% H4 ^4 p) \) f8 } K - return;
) G4 ?' x6 Q2 u3 `3 S$ ?# M: F+ l - }
4 J7 `1 [( a; o2 t0 }2 E) A - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){* b9 D0 C. ]% b) b$ O& v& B0 b, i; u
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");+ B& a/ R( [9 P' c" b% \) [
- }
0 n7 y( m# W9 R/ B6 O - pose.pushPose();
' w) @' B+ K) o* ~, X" n8 B) R - final int newLight = convertLight(6);
& t% S7 i4 {4 M! m3 J4 i. j$ `: ~ - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
& I B: e/ L N7 H+ o - final float lineHeightSmall = (y2 - y1);/ n9 C+ \; s; z5 G& w
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);& L8 W i0 E4 O$ e. [# f/ \
- pose.popPose();1 a& j, Y; o9 C- Q8 g8 \
- }
& M% J) N& @" A; J$ _+ n
% y, U4 S* w0 O3 D& i- private RenderType getLayers(String texture, int light) {1 |+ [% n* a# l! S
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));8 a s }" k. M# }
- } @6 Q" k: Z4 n4 x! i. ~4 T
- 5 i2 E8 e) v; y- P) j
- private RenderType getLightTexture(ResourceLocation texture) {
; A3 g9 `9 a4 G1 j' `# k1 s - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
" a6 b, ^' L t: k3 ? - }1 q+ I, K. [: }( \% _. I; o& ^
: e3 l3 R& n3 t9 x' l+ w- private RenderType getTexture(ResourceLocation texture) {
" c( A* Y5 \" J& q2 P a - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
h3 q% @' _& }/ U$ |" u8 H: w+ F - }
x, B3 F- e% z$ d/ [6 ^) y - $ A2 n, X# E) F" q
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {1 O h& P& x3 u" Z* ^* M& }3 C" Y
- if (cache.containsKey(identifier)) {
) u9 E) F" K# p) U* |6 M/ Y - return cache.get(identifier);4 T$ H- u0 S! ]$ q u
- } else {4 y' z& E3 n7 D
- final RenderType renderLayer = supplier.get();7 K" u! \; E2 {/ G [
- cache.put(identifier, renderLayer);
* y$ U9 n: c7 q* ^ - return renderLayer;& S6 o @; e; q' R
- }1 |1 z2 E: w5 J7 `( j
- }
( w' G5 R8 S, [1 m! @3 Y - }
复制代码 |
|