|
|
. f1 f, n# q# V" j' x5 j
行,这个怎么样
* k0 l3 M2 ~; m; h" O8 ^- package com.xhg78999.mtrfac.render;
1 _: o5 v# k* j# z+ v) _
4 Y# X) O$ q7 D- import com.mojang.blaze3d.vertex.PoseStack;; V- O8 R( @9 r5 ~8 ~# u2 L9 m
- import com.mojang.blaze3d.vertex.VertexConsumer;
# |) \+ ^& |6 v; k - import net.minecraft.client.renderer.RenderType;
: m8 k% ]/ h9 S7 ] - import net.minecraft.resources.ResourceLocation;
# o! H6 u: {1 B, h
5 z. A* I* E9 ?9 ^3 G- import java.util.*;
' D% Z4 H7 k( a( D - 6 ]" o! X9 b) r* n3 K
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
% ~' g' K7 E; y+ D. w; \9 D* j
6 X+ [/ G$ u5 a- v; R- public class LineRender{
8 l* N3 I9 B3 n - private final PoseStack pose;
5 N+ K4 ^2 j9 t* Z/ [8 P5 T - private final MultiBufferSource source;
* c/ }& b3 h4 E( M: ] - private static final Map<String, RenderType> CACHE_A = new HashMap<>();5 B; X; E- |5 a2 X
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
* S; r4 M; H! i7 O0 o* I9 @ - ' B: l6 W2 {# s" T: d
- . |1 B* W" V# R# f* r* I
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
/ i& I: A0 N4 h _& S# ?# ~ - if(x1 == x2 && y1 == y2 && z1 == z2){% s* G' U; T' X
- return;
1 P! J$ z; \ l2 ?9 t9 M; P! { - }
7 i$ ^0 {; H8 g - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){, k2 ^! t& F% T5 @
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
0 T" |# z- e4 f3 t3 a) M - }+ t6 y2 d5 B' K3 A+ q
- pose.pushPose();0 ?" j* J3 \# c: C' K, L# a7 E
- final int newLight = convertLight(6); O" N) ?8 U2 ^* f/ `
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));/ Y1 x$ E. c0 y6 D2 @$ m8 |
- final float lineHeightSmall = (y2 - y1);
! L* _* q8 ?9 e - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);$ R7 x8 D* m7 c/ \1 Y; h+ l+ ~
- pose.popPose();
: g4 S/ E* `) s4 `0 m7 z - }
: g$ \& q1 A1 \: `" N8 p/ J
% C* j' g2 ]. M. s9 J3 \" ^- private RenderType getLayers(String texture, int light) {- g5 B! ]- e" L
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));8 w- Z& v. P( w. f! q$ |
- }4 g2 A2 R, I4 E" Q* L; N/ i
- 6 j/ W6 ~9 J; \" i
- private RenderType getLightTexture(ResourceLocation texture) {. r$ n* s9 |4 W: o
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
, V+ Q4 g+ {5 t h# y, K7 w - }
& `$ b$ ]8 C% H( R - 8 m5 ?4 p1 l3 t, v, o& ^2 G
- private RenderType getTexture(ResourceLocation texture) {
* J- h, V) f$ {0 _' U& G - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
4 m; _! P9 J6 }8 V7 v9 C( ` - }
( q, d3 }9 o! L9 u2 H2 r, W& s1 T8 i
O0 U5 X% C9 ?) T- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {1 G S2 L9 u1 B7 k c4 r5 p
- if (cache.containsKey(identifier)) {" Q! m$ j. D1 S, X; u" h
- return cache.get(identifier);
, L& s" y! X0 Y/ O' f8 a3 Z& H - } else {# o: t! y0 P3 {8 e
- final RenderType renderLayer = supplier.get();; t! n" A7 C( o* h
- cache.put(identifier, renderLayer);
+ N. n5 F4 u9 C$ b' a4 S - return renderLayer;9 K# F5 {/ y# @4 G2 ~ c' d
- }; O& C2 X E" ]3 R i7 R/ M6 t
- }
7 V. M7 z/ E ~& M - }
复制代码 |
|