|
|
0 J0 j, K8 u9 ]4 q行,这个怎么样& l1 @" d3 s2 n3 H k
- package com.xhg78999.mtrfac.render;
% ~; `/ C4 q, f& z - + ^* a- V3 b! F# k# l
- import com.mojang.blaze3d.vertex.PoseStack;+ j2 s/ v# ^% t3 Q( ^3 V
- import com.mojang.blaze3d.vertex.VertexConsumer;
; i2 `, R( E; [' ]3 m u - import net.minecraft.client.renderer.RenderType;- k H5 U$ r+ T9 T
- import net.minecraft.resources.ResourceLocation;
% ]+ o' w! W4 k. U
( A# O1 B7 ?) O6 j% k- import java.util.*;0 o) c6 q/ P2 S$ \4 Y1 x
5 i% N% E6 O" M% S2 h2 c/ y- B) T- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(( x" T3 w6 J' u" ?3 p4 y5 d, m( Y
- 2 j4 j9 s: D- x+ U" e; f4 l" B8 N
- public class LineRender{( @! S6 W$ r" e
- private final PoseStack pose;/ V/ Z0 {* U/ f1 _% h
- private final MultiBufferSource source;
6 V5 }9 }2 u# H, V( u4 f2 f - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
- q) }3 @2 M; a/ p7 L+ N3 c - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();: M, F" S& Y& j% M( Y* J1 B3 E
2 `' u( K4 j7 u! f& a! n( F7 [
5 {" s; O, \& H" | ]- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
' O3 q" i; T4 L/ b9 O - if(x1 == x2 && y1 == y2 && z1 == z2){
# b3 Y( h/ n) F - return;
" L9 Z5 \. `: E, Z: L* { - }
) l& j) S- ~. ]( | - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
) o. w, Q/ f0 ~& e& ~! S* x7 V - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
# q9 w* G N. z; h - }
+ H+ S- e7 \8 E, b9 W! | - pose.pushPose();9 d k# _/ L1 E* _& W3 n; q' }+ I
- final int newLight = convertLight(6);
* y7 @0 n1 |: j4 d- C/ i - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
0 ]0 S) U. s* d - final float lineHeightSmall = (y2 - y1);
) o& [) V3 x8 k& l# y& \' B4 M3 F, o8 a - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);. F6 l; R; ~. H0 T) Y
- pose.popPose();
3 ~; g% U6 u" @+ q1 V7 k+ _ - } \' G% ~2 z5 a2 V5 p
- F% N2 y- Q& n! i) y5 f9 y$ K. Q; g- private RenderType getLayers(String texture, int light) {
$ \5 D# g9 T, y+ ` - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));; {5 U0 f- ~/ Q/ S2 r) N
- }
, k) @5 c/ z# Z$ L - ' q/ Q* l, `# Q$ I% X6 U# ]
- private RenderType getLightTexture(ResourceLocation texture) {6 V# p Q9 B6 ^% h# j$ W, \
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
& W( ]; ^; I: f% O; R9 \; V8 o - }% E6 z6 ^* c! R" P( E s8 Y: i
) U0 x# U* C" Q) e$ a) r- ~! |) |- private RenderType getTexture(ResourceLocation texture) {
% h1 d% g& s5 r% b9 w- c - return this.cache(texture, () -> entityCutout(texture), CACHE_B);* q( V& @0 H; e' u1 S- {; y8 ?: J
- } F/ P$ e, F% k ~
- 5 n Y4 W. _, T% Y0 N( S6 E
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {3 c ^# W2 ?" d% W# M
- if (cache.containsKey(identifier)) {
: l! c. ]% X+ q6 Z. {+ w - return cache.get(identifier);
& g, D0 G/ h; G5 L9 {9 r/ j2 l - } else {
5 H. ]: y. i9 m - final RenderType renderLayer = supplier.get();
2 V2 D |! `, ?' J - cache.put(identifier, renderLayer);, G9 w& `& p w; W! W# Y
- return renderLayer;' M3 D+ b+ a1 Z% n6 [
- }
& p0 C( V% W: n8 n) _ - }4 c0 x$ s" g) z, ^0 q* y) Y) g# ?
- }
复制代码 |
|