|
|
' E7 p! p( P7 K' |. d b2 \* s1 N行,这个怎么样 t1 F- B3 Q3 k/ k9 Q
- package com.xhg78999.mtrfac.render;: H: X" ~. o& v7 Y$ E; W
+ R. l- [& Y2 \2 a- import com.mojang.blaze3d.vertex.PoseStack;, C3 L! V% s \, W) I8 f1 @( Q, Q& `
- import com.mojang.blaze3d.vertex.VertexConsumer;7 Z1 |- m1 j8 h+ p: B% f
- import net.minecraft.client.renderer.RenderType;
% x K/ p( u! }+ w - import net.minecraft.resources.ResourceLocation;; {3 q; A, e# [0 h
- % g1 U4 m) L4 s6 k/ N5 F
- import java.util.*;
/ Y7 l. D. d6 S
' P- h- Q; o" \2 F- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
. G9 }. k6 y4 |/ p - ' S3 u% b+ x$ j: F, P0 Y, W
- public class LineRender{
$ o9 B% I$ [# x7 F' { - private final PoseStack pose;4 F0 |7 T K& w
- private final MultiBufferSource source;
6 S9 K3 `2 v/ O: A - private static final Map<String, RenderType> CACHE_A = new HashMap<>();- d, G# w( V7 Q- U5 N ?
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();7 |% g4 i- C( Z2 ^2 p' g; O
- 0 t7 s8 w$ k6 L( |% u
4 D2 i0 [$ P6 p# Q# o0 B- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){/ \. B) p% S6 O, p2 H
- if(x1 == x2 && y1 == y2 && z1 == z2){
5 R2 p, u& a$ r1 r- M1 m, O& Z - return;* p$ x3 @% B2 [0 I8 i* l( t; G
- }
+ J9 H* X; I0 T& K2 [( a. E+ z( d - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){5 \# X1 ]; E( i8 t: I
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
, S* T" i, r$ F8 U. Z - }
- b2 i: X- r: m - pose.pushPose();
+ c: f7 l0 q2 v) e V) F - final int newLight = convertLight(6);3 ^$ h, m: T; O# v) o+ x
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
- X$ n; R D5 \5 Q1 [* w - final float lineHeightSmall = (y2 - y1);
6 ?0 Z8 S: X- W( }( j - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
* C, I( k: J/ q5 I1 H3 F8 E - pose.popPose();: p; N# _- O- K3 Y E1 {
- }
9 V( |6 b: Z8 y0 H7 N, M8 U7 Z
& C" h3 m) | _' b' M! n" g- private RenderType getLayers(String texture, int light) {( C: X7 C3 M& e8 N$ n; d% E
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));) @7 G; X6 s. e" d; J2 g+ Q
- }; g* I8 m# ^( i! u4 x3 {& Q
- 7 i$ F& r/ x' i/ Z4 J2 k+ U
- private RenderType getLightTexture(ResourceLocation texture) {
& I! g5 S6 v* [* P - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);, @/ z' Q8 @: H* O$ W* ]: ]
- }
+ b, g/ T: f5 A0 U
8 X8 f) a4 _0 A3 P7 \$ Z; M' N- private RenderType getTexture(ResourceLocation texture) {
9 l8 K, x3 F2 Z3 ^. {5 y# j% t - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
a- K+ D$ A! n5 p - }
6 B. b [6 N$ u6 e: t/ i! T( {
: @' |" m- S9 h' r7 ]9 {! n- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {5 V, n/ J. I3 a3 [
- if (cache.containsKey(identifier)) {
( ]" Q4 i3 V3 a& q. w; f - return cache.get(identifier);
4 |+ _* v* L7 W$ _: P1 h - } else {+ S5 x6 c" l! y9 G! a
- final RenderType renderLayer = supplier.get();
+ M% o3 {. \) v3 i* ~6 R - cache.put(identifier, renderLayer);
2 e9 F& Q& N2 }7 h, N: h - return renderLayer;
% F% h; A5 Z6 D O+ Y - }
7 j- ~( c) d/ \5 }( [ - }; G7 \, R8 s: V" w t& c6 x
- }
复制代码 |
|