|
|
" m" C/ }/ ?& v# ^" F) f
行,这个怎么样# O% L" \! s+ j% m
- package com.xhg78999.mtrfac.render;6 A7 Z- G% U- t: [" B* E' M, Q
0 D! v# K1 u* y. m* {4 _5 r: [- import com.mojang.blaze3d.vertex.PoseStack;
# _" ~# W! r4 {1 s& X/ G - import com.mojang.blaze3d.vertex.VertexConsumer;
" _0 T; R" \ D6 U5 a - import net.minecraft.client.renderer.RenderType;5 @ t$ I$ V) q) s
- import net.minecraft.resources.ResourceLocation;8 X$ m" o+ G1 a& j9 I
6 @9 x+ [* ?* {- import java.util.*;
0 f& R* v$ z6 L& [ - $ L; z1 G# P; Z
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
5 z0 I' A. U! @ j - $ h7 N) s: ?( |7 z& z+ C3 r
- public class LineRender{; G: w! d: h# Z, a# f
- private final PoseStack pose;4 a. c/ R! @' P5 G. D; t' K- C
- private final MultiBufferSource source;
1 B- l; G# i2 Y1 _+ S- | - private static final Map<String, RenderType> CACHE_A = new HashMap<>();$ k+ \, R" W3 G6 J
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
& C$ q! }6 q' R; A9 Z0 J' F9 R# M; q
4 c I0 v; H; O$ k% Q8 Q6 X- & Z6 I4 w- ?" @: F" h7 [" t
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
- x1 }. w# }% Z$ z8 k E - if(x1 == x2 && y1 == y2 && z1 == z2){
1 {* o6 f! t/ W q4 C" F - return;
6 T% F+ N: F3 z& t% R( E9 Q- }# F - }5 c4 ] A# y: d0 c& }8 Z( h$ L
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
0 c2 X% l/ j5 N; o6 f+ ]2 z+ J - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
& ]" N" X7 W+ l9 x4 u! k0 r - }- y, O1 I9 ?& q3 ~% B
- pose.pushPose();6 i" R3 t$ ^% x$ t2 J3 }+ R. r
- final int newLight = convertLight(6);
f6 X& Z+ O/ D- n1 t k8 N$ S - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
6 i, f& i+ q1 h- f @; B; X - final float lineHeightSmall = (y2 - y1);
* R4 ~; B' Q0 I+ b7 Q - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight); t: S+ U) b8 }+ |: s; _
- pose.popPose();7 Z, r L6 Z1 q+ {
- }
6 Y3 h# l% X/ j. J0 I5 C5 V3 s - 2 U6 X5 B' M' E, b
- private RenderType getLayers(String texture, int light) {
* @' v7 {: ^6 v; s* I, t4 A1 m - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));! ~' t) l" O7 `) }
- }
2 W6 j1 e0 H/ O, m
4 ^! h" O0 g& B+ E; Y- private RenderType getLightTexture(ResourceLocation texture) {
4 R: q2 Z6 {* v0 ~: p, s - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);/ I `6 P! L- P2 P m0 u T; ^2 L
- }# x5 j1 @- Z* i! b# O D
- 1 z: p+ \; ?# G/ ~0 L k3 M
- private RenderType getTexture(ResourceLocation texture) {3 D* x9 D5 p! {. S" n; M- @; a
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);' O+ |4 M" ^- K' P' }( t
- }
u, B. c' ?8 _6 @- s7 M7 D
9 j/ {5 Q; G% Y) y- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {, v( Q6 J+ j+ J$ Y! q
- if (cache.containsKey(identifier)) {4 Q; t+ W& U7 Z7 Y
- return cache.get(identifier);# s+ w s7 e! u5 t: _
- } else {
" b7 o, t& I5 f" i+ E - final RenderType renderLayer = supplier.get();. j7 _1 R$ H w$ _0 u
- cache.put(identifier, renderLayer);
: U/ T$ b$ o$ l. M% K0 a0 j - return renderLayer;2 g# c, n) {& m( x9 S1 n
- }
1 K& ^( j& }* f( g/ g - }+ H3 L3 K' q% i4 H
- }
复制代码 |
|