|
|
, ^! E( o2 a2 D6 v4 Q! m- k) e行,这个怎么样
6 k) Z- K2 h* l8 r& e# t- package com.xhg78999.mtrfac.render;
9 `) U6 y8 ?! s2 O - / O& @! v/ X, H3 z! o
- import com.mojang.blaze3d.vertex.PoseStack;
, a: \- w+ u3 c1 J0 L; |; _; k - import com.mojang.blaze3d.vertex.VertexConsumer;
6 J+ L, C! d4 J* K' U& ?$ ^! F p - import net.minecraft.client.renderer.RenderType;. w( Z9 V) C5 f. _0 [5 Q
- import net.minecraft.resources.ResourceLocation;; u, _6 u1 V1 A2 }
- : w; r% D) c1 U, u$ u* E
- import java.util.*;
8 R% U2 n2 F5 \4 m
: I8 X2 K- M2 F# \1 a3 x- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :($ P% w% Q7 V: q& |/ z# C
1 j, G' m+ r" [3 u) \9 r+ K! c- public class LineRender{) W( u* m/ x3 [9 |" e
- private final PoseStack pose;
& p0 e, @) e3 t) V6 X" Y - private final MultiBufferSource source;+ e$ m4 N8 _) A! i& H. S% e
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
3 _' p! E# B4 R. A - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();7 F) j4 u( W: s) a; h5 R# q
- : e/ I6 K2 L7 ?+ {
- * h" v: ~1 Y( X9 ]
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){: r! Y+ f' u3 e( y: N- h8 k
- if(x1 == x2 && y1 == y2 && z1 == z2){
4 b+ W/ c7 Q0 l) ^- y* X - return;- r7 j: S) f+ P( B g, M, M- L
- }
" ]% H: E' h9 M. a - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
, R* d5 p- ?4 Z' @( t6 W: T - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");+ U; `' N; y+ Q/ n) B7 G
- }7 f; [8 V8 h- Z1 A% [" T
- pose.pushPose();
' P" u r/ v( o$ O/ b, M - final int newLight = convertLight(6);3 Y4 s8 K9 V! \9 v# A
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
( v7 l/ K- X" c4 `2 E: K/ K; y; } - final float lineHeightSmall = (y2 - y1);
$ K- C$ m& x: H* i* U5 f - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
4 I7 V6 I h, Q- r1 _) c% z8 Q6 O - pose.popPose();. a& v) f3 X0 j2 z4 P7 T- r
- }+ s. Y6 |4 T* j$ Q4 [5 S% Y
1 a6 ^$ M. [# T- Y; b# a1 R" f/ a- private RenderType getLayers(String texture, int light) {
/ [* ]0 |' j0 P- r- s! T - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));# r: s5 M) m# Q
- }
; e+ j# H5 R) P- D6 \% ` - : s( T& b$ F) d# E. Y
- private RenderType getLightTexture(ResourceLocation texture) {1 O! G3 U( X ~/ H
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
/ r0 _7 r9 \* @( P - }1 Y6 w7 ?, ?1 a6 b
( h- ]) \$ t8 z* R- private RenderType getTexture(ResourceLocation texture) {+ S) x4 m6 n3 k9 J m
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
: H- D+ h4 A6 V. i$ P3 N% ] - }
# H& `' h* ^/ p* r - " L- e, k0 `8 {
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {$ K1 N- q! l6 Y* v( p8 C# p
- if (cache.containsKey(identifier)) {
) }5 T' {' z/ ]+ ]" U( g4 P: ^ - return cache.get(identifier);& V+ U7 o) h" V) N
- } else {+ c/ C, U1 V7 g) {7 @
- final RenderType renderLayer = supplier.get();/ L0 Z9 r, E6 A) r$ v/ K5 m
- cache.put(identifier, renderLayer);
- L4 U7 Z# m# {8 d; j - return renderLayer;( V( W" @% R% d. o0 p
- }
% f* m/ x# C1 i6 l - }# |: V' d1 @6 W- ^8 f
- }
复制代码 |
|