|
|
. ]; C8 F9 ~; ?行,这个怎么样
% Y: Y# M9 l9 a' @1 v- package com.xhg78999.mtrfac.render;
, q5 ]( U' t' p3 e" n) J
+ N) Q Q3 \, `! v; T% q( |- import com.mojang.blaze3d.vertex.PoseStack;
* d6 ^. L. j( z# l$ S1 U/ D - import com.mojang.blaze3d.vertex.VertexConsumer;: j$ K H. a" Y9 I3 k+ ?# c4 h# `
- import net.minecraft.client.renderer.RenderType;" ?. P' {. n2 G6 W/ ~
- import net.minecraft.resources.ResourceLocation;/ t/ h, @/ t$ U" W! c& {9 U# D
* r, u& }; x- B: @- import java.util.*;
9 O! y- a" S! e! V9 z
n. a$ P5 b' k- T4 j7 ?: q4 {- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
% ?/ ]4 o& Y& N$ |5 m, W6 j5 W
+ P3 ^. U: u3 f6 G- }6 B; O- public class LineRender{
+ L$ l2 N7 Z1 F - private final PoseStack pose;! X) g# U! P( q1 ]! i
- private final MultiBufferSource source;
4 b" c( |7 i9 i - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
6 C# @. q5 a0 | - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
' w7 x$ T+ t1 U4 Z# v - 3 w5 I! Q" h5 M6 Z& L/ Q
- s; T# ? W/ h8 K- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
+ N9 X1 ^' f2 |( |4 C, \2 k' p - if(x1 == x2 && y1 == y2 && z1 == z2){( a ?$ O4 r% j. I5 h% u- `
- return;8 |8 j4 q, e, i) E4 m& { v, L
- }
& X$ U( B' v0 ?' W+ |- \, G - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){5 c: Y2 _( _1 m& U& v9 G! e6 G
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");1 r4 q) U4 q/ x5 u
- }
* ^& F* M: \0 q$ Q' ~ - pose.pushPose();6 i3 k9 Z6 @2 s7 ]
- final int newLight = convertLight(6);
8 L' A" ]& A& I% x/ [" M6 v* i - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));' `3 C( h! {! e* | h! o
- final float lineHeightSmall = (y2 - y1);( ~7 c& V) ~1 j! l3 T
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);3 b l& @+ X: C5 Y" ?9 y$ l& o# `
- pose.popPose();# j# t& D. V2 W; A6 }" z
- }
) M8 I; z5 @( B/ h - . q- H: e/ w; @
- private RenderType getLayers(String texture, int light) {0 @8 N. b: @% a i9 j5 G: [
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
2 x' P, u9 i% @* t; v - }9 t: a4 I: u: d% W4 J0 M% B
- 5 r3 d( O, g( x4 ]
- private RenderType getLightTexture(ResourceLocation texture) {6 {! K& u* Y1 o% }; [ D
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);/ D8 l( q& B+ m4 T- q4 u0 ^
- }3 I9 p) ~! F+ [1 X
; k2 M) b' J6 P8 W3 T: m- private RenderType getTexture(ResourceLocation texture) {
& Z; R. C4 I! E* j- V! S9 W! G - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
; }7 `" Y0 u+ V5 w) D - }) g R+ ^; }$ g7 q
; U- ? V9 k, m! U0 X$ ^- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
' o# Y1 [' f% ~5 J4 x# f - if (cache.containsKey(identifier)) {
! D( t4 F" f: N3 |6 J - return cache.get(identifier);
: U4 [, K1 b+ t2 c% g6 B. s - } else {
0 E4 Q: R( A" | - final RenderType renderLayer = supplier.get();2 W& T1 F/ h; z3 t
- cache.put(identifier, renderLayer);
' Z: q9 M; ?' P, }# @. } - return renderLayer;
2 ^% h/ s$ I6 b1 I; e - } O7 k9 t" C U
- }
0 x! L2 t+ t5 O4 W, f( U! O+ q - }
复制代码 |
|