|
6 b* W' b* S* ]7 [, Q" ?) A! J. N
行,这个怎么样+ f7 c9 V* M4 {2 A5 R+ n9 A; o
- package com.xhg78999.mtrfac.render;
% R% |* O/ j" }. _. L5 r - / ~& j) N8 g+ J( u5 l: y/ [
- import com.mojang.blaze3d.vertex.PoseStack;
* t) M+ e7 v) B: u# G+ S! [ - import com.mojang.blaze3d.vertex.VertexConsumer;
. O, l8 Q+ ]* S5 s# N, I$ b - import net.minecraft.client.renderer.RenderType;
0 _2 E" q+ t1 N - import net.minecraft.resources.ResourceLocation;
# G* g0 o; h1 O" Z
3 d* ?) p% A/ e3 x- import java.util.*;) e I5 c; L0 T5 Z8 J) z& a: O& x
% f$ P2 H% J9 |+ |; ?! [% `- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(# }! q4 X9 E: S$ s8 W
$ z8 z0 c& Q0 V- public class LineRender{3 Q" h% q9 d1 _1 j6 [" T
- private final PoseStack pose;
: \3 V; i' g6 `) B4 F - private final MultiBufferSource source;
/ V6 r! F8 j2 J8 {% t' s - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
5 p; O' y+ C8 ` - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();/ k$ A1 P; F. p8 x/ U
- 0 g* E8 i4 B9 G# u7 ^8 O s }! u
- ( W9 b* p. G3 [- b; C/ Y
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
- D7 E9 B1 Y0 u$ n* w" I - if(x1 == x2 && y1 == y2 && z1 == z2){
8 d! v' s, v G G3 A - return;4 n2 m s& [4 l' P2 d8 Z: c& Q3 @- N
- }1 k' f4 U. T0 ~0 X4 U) t
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
/ I2 _- C) z% ], w; a [5 \ - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
! W' ]4 H. G; G# G9 s - }5 [) m" Y8 `/ L( x4 U) _
- pose.pushPose();7 Z* K/ z D, z# H2 R5 v1 T
- final int newLight = convertLight(6);
5 L1 U& F( ^3 {) p9 y) T - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));) ?. T! X4 e9 A8 u8 D$ s3 p) k3 [$ w
- final float lineHeightSmall = (y2 - y1);; w4 j4 v! y7 o7 f/ x1 C4 V
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);. U( z8 ^# g1 ~) ]1 T
- pose.popPose();+ E+ R# N' l+ v. U* |; V: A* V1 x
- }
7 Y& `9 {9 F9 X/ {0 D3 X1 t
& h2 }0 U5 I9 [, W X9 o; x ~- private RenderType getLayers(String texture, int light) {
9 G9 ~1 y9 S. Q* A# T: j - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
5 P* H/ ]" Y, }1 L R) |5 e5 Y- i - }
* ]6 r4 L- I: O! Y2 B4 K5 j0 O - 8 b% G1 E. Q/ r" J
- private RenderType getLightTexture(ResourceLocation texture) {
) J% n; M8 }: n: F5 c: A8 e5 N0 I$ _ - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);+ @' ]5 `; y6 u" S
- }7 K9 C s9 Z2 W2 I" ?
$ a0 W' g c/ _; i j$ v$ @$ |" F- private RenderType getTexture(ResourceLocation texture) {3 |6 _/ f9 o5 i# U7 o: Q, f
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);) |6 i1 P) r0 |: s. t
- }3 R6 k/ M1 D: [' I+ G) x
7 C- q4 Q9 g0 f( h- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
- y0 J, y1 l- t# E3 P - if (cache.containsKey(identifier)) {# V' o3 W# V2 X9 X$ J2 H+ U
- return cache.get(identifier);
m) R$ z y: Y - } else {; x# W0 ~5 M3 e
- final RenderType renderLayer = supplier.get();
, b7 J# s: q* d1 Y3 ~! t" _: b# W+ r( k' l - cache.put(identifier, renderLayer);
, u- Q! A5 e% U0 U2 [6 F - return renderLayer;
$ l: d" t: q( k& L# G; h" S - }
" b+ {6 Q; K+ W/ \; `- I# X - }
# t% `0 ~2 E* f% V$ y - }
复制代码 |
|