|
|
3 U l% e/ _& Q! f
行,这个怎么样# n1 R' k) \9 O
- package com.xhg78999.mtrfac.render;
0 n v! p( }4 i) m2 A( z7 [/ \
+ {0 P2 p& |1 y( u& D& Y- import com.mojang.blaze3d.vertex.PoseStack;
) T. J8 _" {" W0 p. s2 m - import com.mojang.blaze3d.vertex.VertexConsumer;
' m( d6 Z+ v; A+ A7 m A( { - import net.minecraft.client.renderer.RenderType;
. L) Z6 ]0 ~ f" |/ E& m7 r. r - import net.minecraft.resources.ResourceLocation;
0 ]% X2 |& j# }/ P3 z1 o7 s$ S
1 [; m: m6 E. r" d/ J" ]- import java.util.*;
3 W. b' f h7 C {+ `
1 ?# R4 K! A' _4 ]- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(: `$ \" P) z6 U* h
- ) ~) P" ^* Z8 z, j3 `( M4 {
- public class LineRender{
2 i# X3 S) K, |- A - private final PoseStack pose;
: N! K4 J' ^8 t, M+ C9 w$ M - private final MultiBufferSource source;
% k `1 f7 u9 r3 w - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
8 }: n* C) w9 d3 v( j4 v - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
- i J/ H- m5 e# ~3 F, W - ' ? A& w) j& A' s8 r8 Z
- 8 e' V, I$ o8 H
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){; g6 _- N2 [+ M b' ^/ O
- if(x1 == x2 && y1 == y2 && z1 == z2){
) d" V6 o6 K& p/ w2 o2 s; G - return;8 s* k# w. T2 e2 c; X3 H6 j( k
- }
* S& A X! b6 m1 a8 t - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){* b/ B( E: h8 E! @2 Y, W) T
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
! W7 _( P: v) a" A. X8 S9 ], q - }
" V: {! {+ U, u m. N - pose.pushPose();0 r5 `( ^' _- M% b0 k- |4 D
- final int newLight = convertLight(6);- k2 w, X: q: _
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));6 k( Z% I& ^$ r: B$ z7 j
- final float lineHeightSmall = (y2 - y1);) ]$ M$ Q v, {/ G/ g
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
' Q! W" S; i& r6 R# D! z - pose.popPose(); t$ q* o7 o7 B
- }+ ?% O+ M! q' G# {
) M& y- x) L- v9 z5 f% F! a- private RenderType getLayers(String texture, int light) {
; d$ x& ^- O" C - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));/ r, j5 ~. I$ I2 s6 Y9 k3 v; |
- }5 z: U* \: D. t- Q
& B2 a# Y/ J1 j6 ^4 V0 O4 J% q" g- private RenderType getLightTexture(ResourceLocation texture) {
$ U; F, m% T) ] - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);+ K6 r2 I( u, l$ j; f! J9 K
- }
3 E$ H4 C2 j( j$ e: M P
# P# M, e. ?2 Z5 F" n- private RenderType getTexture(ResourceLocation texture) {
: a5 J* L; P4 y9 q, {0 c% O - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
& @& i4 w0 w* T6 }; H$ ~% O - }
1 v/ h3 |) r2 g, I8 z" b
% z& z+ c/ n2 I$ `' }; d, Z- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
9 H: d3 n4 N) S- T - if (cache.containsKey(identifier)) {6 a# b' P7 z: A& Q6 o5 n
- return cache.get(identifier);
8 G4 n4 u. |* I0 A' k- y9 c - } else {
" q! t9 W( R4 ]1 d: Y - final RenderType renderLayer = supplier.get();
; M# U3 m- H; @1 R$ e - cache.put(identifier, renderLayer);# H5 `: B$ b8 u
- return renderLayer;+ `: V8 R2 f; F6 I' x
- }6 `( }0 E* R! m6 I% K0 o; b
- }
, f, n8 X# A. ]( s - }
复制代码 |
|