|
|
6 c( ]% H$ {8 ~# r) B
行,这个怎么样8 L! d% L9 i( Y) ?
- package com.xhg78999.mtrfac.render;0 @" O8 ?1 i E- m3 T5 p
- + f& u+ @3 P3 s5 N% v# S' U6 I: S& o6 k
- import com.mojang.blaze3d.vertex.PoseStack;
. N! s% ]* ^: I1 h* D - import com.mojang.blaze3d.vertex.VertexConsumer;
" x, x7 N3 I; v0 d - import net.minecraft.client.renderer.RenderType;
5 [; F7 t0 R6 U1 M - import net.minecraft.resources.ResourceLocation;* h% }1 Q6 {$ K+ ]" L V/ Q
. I* l- w7 p' V3 v- import java.util.*;. L5 \, a. P, `/ Y: u, [0 z2 [
' j8 T# m" f8 Y! I- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
7 O% \8 F% b5 u1 Y
c2 y) H# S' ]- public class LineRender{$ o9 @: q2 {0 p( z0 S [
- private final PoseStack pose;# @1 E% L* h" }: C( T& ]8 O4 c6 v$ S
- private final MultiBufferSource source;
: `% t# }9 u J9 b) \2 \ - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
, p2 H' m8 b% @' \ - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
; Y, s# O% e- E: a- s9 X7 }* w - & }& t! d% I) R4 ~
3 T4 h% `) T1 h- m V( ^ s- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){# _. l/ b( q- }4 }
- if(x1 == x2 && y1 == y2 && z1 == z2){- ^# c0 f% }. f" \
- return;" E; H; z) f" N& j
- }2 [6 ^& w- C$ z0 f' S
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
1 p* r7 K% C) h# P7 K3 c - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
: ?% c, P) N; e' K8 j - }, v3 ]* Q2 K4 b7 j
- pose.pushPose();
, e2 _9 I( i4 u( ` - final int newLight = convertLight(6);
# p* h: H# A+ U" D3 B9 W3 c9 V - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
, D, Q& g1 O( F, b: V' Y - final float lineHeightSmall = (y2 - y1);
, l8 K- k5 r; p2 r - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
' P: l! n) g' t; z- w Q6 D3 ] - pose.popPose();! i+ R! ] @! @7 z
- }
+ X8 C* h% W4 |1 g7 J
+ @( `! Y+ y1 `& L% z3 Y' e- private RenderType getLayers(String texture, int light) {
1 Y& T/ G4 \7 r$ U/ | C - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
+ w U7 T& H; l* z& L - }2 [4 J2 i2 m9 i' h# ?3 [: }; v
- Z- x4 [: ]4 q- private RenderType getLightTexture(ResourceLocation texture) {3 L" g5 ]) K9 ^% {; o/ D6 g' {
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
8 l( p4 L" K2 m& u% n _/ W) V1 a' w - }; I! |; H+ T/ z' e* i+ J7 U
- 2 o; E$ }6 J% ] E4 G
- private RenderType getTexture(ResourceLocation texture) {# V! w: y. W( a* e5 i$ R" `$ {
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);1 L4 G0 \4 N; f6 D2 v- V) m
- }
; |0 c2 V+ I" q
' } f# ^( j: Y/ S- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {9 E2 f& H6 K7 B9 H/ `! F
- if (cache.containsKey(identifier)) {
* Z2 f* ~' Z* K. t - return cache.get(identifier);
: ^ l& y3 }: z9 ~: E4 |2 M8 C - } else {
2 _7 W+ z5 Y e - final RenderType renderLayer = supplier.get();
5 C! q7 x5 x) I9 u - cache.put(identifier, renderLayer);$ ]- [3 O6 F5 j
- return renderLayer;
' A2 @, p$ e$ k7 S - }
2 P8 [. t8 E& T0 Q, u. D0 U' w0 l - }
& T/ V1 b( [7 n - }
复制代码 |
|