|
|
. `+ y! B* h% V3 ]; _2 _( B2 ]
行,这个怎么样
3 N( M5 ]2 y& q8 m- package com.xhg78999.mtrfac.render;& k: N2 M2 I; J
! F# O, S V# @* {# s, I- import com.mojang.blaze3d.vertex.PoseStack;8 c0 e) d- Z, S+ ^: B+ ^
- import com.mojang.blaze3d.vertex.VertexConsumer;
& B# v: `2 Z* ?! |6 i' s - import net.minecraft.client.renderer.RenderType;7 k) T, c7 ^: q( u j
- import net.minecraft.resources.ResourceLocation;
5 D, m4 a3 ~( d9 S7 l - ( h" }$ s3 \9 ?4 q& e
- import java.util.*;
, ^+ I% n" M( }
# t& @( |) F& I* ?$ u- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
& `9 w' u. M% n
$ ^% S9 K9 \ Z6 g7 S7 Y! j- public class LineRender{
3 Z3 Y' ~$ {# F% P1 k" |, } - private final PoseStack pose;! G, M4 n, x$ g6 C2 s1 `
- private final MultiBufferSource source;
) u# m c$ |, I. S - private static final Map<String, RenderType> CACHE_A = new HashMap<>();- E& [ U: W. F( k
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
+ b, J5 t0 {% B8 Q0 s - 3 _' _8 O8 `3 \! A
7 ]& X, M! l; l. a8 R* {6 T8 [# J1 @- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
1 R# J( B9 d3 c - if(x1 == x2 && y1 == y2 && z1 == z2){4 ?6 F2 D7 T* A8 W& u0 c
- return;: P7 K |( k& {5 S' Q
- }
; j! I+ S# c5 ]1 K2 D - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){1 ^! \, m' }5 B5 P
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
+ C m* `( l3 | C; n3 G$ F! n4 g - }
% e N$ e. B! Z - pose.pushPose();
! o3 Z0 \8 x1 D8 G, B# }4 I - final int newLight = convertLight(6);2 W. e, X3 b8 V& `4 q
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));7 S; T& _1 ]) M5 @
- final float lineHeightSmall = (y2 - y1);
1 [2 c) q) @/ Y2 U - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);. ?( v- d$ K; Z: N$ t# j
- pose.popPose();- T2 T) e7 g$ K# {/ M/ o9 E
- }
K5 S! l+ E3 X7 N: `
* |* s% O5 F" s: T- private RenderType getLayers(String texture, int light) {
1 h' [/ N2 Q7 ?; }9 m* D S3 I - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));9 f* A4 K: A8 a
- }
, B' V% v, V$ t/ M# Q- r1 p& c - ' X @: z5 Y0 s; D4 s+ B
- private RenderType getLightTexture(ResourceLocation texture) {
( m+ i5 P$ U, t+ W - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
; k f1 W7 t7 E5 Y" j/ E+ f - }
% B/ k) r$ l9 M P, t3 z* ~
r/ S' m" j% Q* S, q- private RenderType getTexture(ResourceLocation texture) {7 ]+ J) Y$ y' \
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);/ t7 x7 |' ?: J! v
- }
3 t# g, a# g. {$ \. D
( q7 w# l# o# g1 a! c- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {4 Q. m; d- } K9 O
- if (cache.containsKey(identifier)) {- P* {/ V. j: d" z" Q9 i* P6 p
- return cache.get(identifier);
/ j8 S) N- V O: a K% ? - } else {
. X2 E% f8 I1 h1 n - final RenderType renderLayer = supplier.get();, y* ~! k% w! H. _+ y0 y9 G) U2 L
- cache.put(identifier, renderLayer); ~7 p8 ?( e) q- n6 C
- return renderLayer;7 T4 `: S2 t9 j0 Z1 j' |
- }. g1 R0 d" k6 y
- }3 p A! A$ }: G( F8 o1 h
- }
复制代码 |
|