|
|
5 k. u+ a' K- X! z6 I
行,这个怎么样
+ F+ N3 s; }4 ?5 ~/ z8 {- package com.xhg78999.mtrfac.render;- X R- o$ i7 Y! L' Z2 a
- ; E8 ^1 ^" [: Z6 x
- import com.mojang.blaze3d.vertex.PoseStack;& ~2 ^. e$ ]% Z& N
- import com.mojang.blaze3d.vertex.VertexConsumer;
: S7 M0 a% u1 O - import net.minecraft.client.renderer.RenderType;
) [ E P4 }3 [* E) m; l1 n2 f z - import net.minecraft.resources.ResourceLocation;3 G" U% M, _+ i: I
Q3 `3 e! O7 F J) P* O- import java.util.*;: s7 \: I& U& a2 D! j$ Y
' V! A0 A0 W3 l0 _# ~7 k- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(! b D7 m2 Z% Z# o- n% S
5 E3 k$ A6 p! a/ \! B b0 j& I- public class LineRender{
$ s" Z2 X( u( i7 W - private final PoseStack pose;7 m, F: ?4 o2 Z" H# R% e
- private final MultiBufferSource source;
# }4 Z1 ]; @9 B% O0 G$ H" ~% Y - private static final Map<String, RenderType> CACHE_A = new HashMap<>();0 f6 z( U- [& j* s( [
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();" D) m) `7 O8 m" m2 w# P( T
- ! h/ l4 r& X, V; v! v
+ y4 g; Y5 o. F/ r$ z- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
- o! s' l0 e l2 ~# x8 J/ v B1 f' O - if(x1 == x2 && y1 == y2 && z1 == z2){
+ ]' a' V- p1 [4 [8 i Y - return;
' Y0 a( m$ r8 }3 {! @ - }8 Z1 S, D! ]7 c4 X5 [" T
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
* R4 x7 a W* ~. h1 ` - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");0 h" }& ?: q' U# p5 M
- }% \! K" c7 ]' ~! I! W5 ~, r
- pose.pushPose();
8 r! d/ X' }4 J. G8 I3 i7 x - final int newLight = convertLight(6);
, l j: p+ Y% Y - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));% h+ R3 p5 _0 t& d0 U
- final float lineHeightSmall = (y2 - y1);
$ H/ B6 E' V3 ?; M7 N+ ~5 t( r. m - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
" V# k6 d9 H% W% }, a - pose.popPose();
* U/ Q1 B- K( N' Y- C, T, W - }
4 P; I) C. E: Q. ]# _& m- g
( C! [* V' A( d! [0 {- private RenderType getLayers(String texture, int light) {
* y3 A3 L6 Q! Q' e - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
( F" \8 n/ N% s1 B& l1 q - }
- N: J2 S7 W9 I, |6 o9 a7 h2 K - 6 }% f" b, L, h) z2 }
- private RenderType getLightTexture(ResourceLocation texture) {) ] @, k( s) c* Z# x/ |9 a8 ?0 \
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
/ L& Q" ]8 T `. L0 }5 W5 q% l: O - }8 q+ [, N1 \- y2 ?5 p: @8 G
( i/ n2 L$ n8 c: x- private RenderType getTexture(ResourceLocation texture) {" O3 {# i7 [$ T* K3 \# C
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);% A3 z' H% m D P& L4 E3 K9 n
- }" |0 K- `1 G, [4 b8 j
# i" ]6 z4 @1 \. n- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
+ `" L0 F: ?; ?, F, C - if (cache.containsKey(identifier)) {4 ?# k8 z* `5 f6 c; {
- return cache.get(identifier);
2 `/ C7 c% h$ l0 ?7 g A2 w* D - } else {
/ H% w4 V9 h6 N* { _ - final RenderType renderLayer = supplier.get();
, }* z u/ G; ]' w8 h# V! x7 } - cache.put(identifier, renderLayer);
1 f7 ~! A8 g8 I, W, _: \/ t - return renderLayer;
+ l! L) O" T% q0 K" O/ Q7 u% f - }
+ E1 ]( b! k1 p6 g9 J2 z4 I - }
8 r( h H, `1 \# _* @- r+ N7 Q - }
复制代码 |
|