|
|
8 o w* p& d1 r9 `行,这个怎么样
) z f" S. A9 [/ w, t" Q* }- package com.xhg78999.mtrfac.render;
0 T$ r" p7 [! ?1 j# K, G
& Q% R% O0 M4 Y, e+ J4 x- import com.mojang.blaze3d.vertex.PoseStack;
+ z" e9 a9 b, M: p0 e6 H - import com.mojang.blaze3d.vertex.VertexConsumer;. C' n0 z( n" }% E. o6 L
- import net.minecraft.client.renderer.RenderType;- ~! @6 ^* x ]8 P' d
- import net.minecraft.resources.ResourceLocation;
: s2 I. c% y* O5 V7 q. ^
" H- W+ z% Q3 Y* V ], ]! a- import java.util.*;
' X8 [9 ?3 P9 t; B* \; d% a5 _ - % ?2 M* C* q3 e% G7 t2 h
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
( v, P8 M2 O# e8 q' }' F, N - % C# h1 @0 k' N* S$ y" J
- public class LineRender{7 t6 P8 L& X w- c; p6 C
- private final PoseStack pose;3 e$ Y/ N+ [* v8 b3 ~& v* s2 ?- s
- private final MultiBufferSource source;8 e5 _4 j& [: M6 \4 x! p
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();- e* Y N( d( D% J- P! a
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
- M, b* q5 q* } [8 |! O; R& f - 4 R/ y p0 a/ A3 g
+ b- E* q6 \: }/ R T* q- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
8 z5 K* L# k' Z: l8 }2 E# I - if(x1 == x2 && y1 == y2 && z1 == z2){
; l( ]+ k1 k/ m/ h* E/ t - return;+ _8 @) O0 Y. d6 W
- }
. G: {0 J) Q y3 [; K - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
. W* e; V0 q: L, v# u - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
; N4 r2 M- n% S7 {( g+ O - }
; f4 ^ k2 x$ o3 t$ ^; S; h( u - pose.pushPose();
* c8 k2 I* X& J% ~+ l; {. n - final int newLight = convertLight(6);& S* h. K7 Y% V+ C V! n
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
/ c1 Z! T' N! i# F- G+ i - final float lineHeightSmall = (y2 - y1);6 d6 u+ M* a J! P1 R
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);2 X1 O% o+ [7 b
- pose.popPose();8 {; B, s, j5 m+ W7 e/ u: ~( c) v
- }2 v) ?' T# G' N; U+ s0 x4 G% T9 u
- , |" @( b- n2 [( i' R6 Z
- private RenderType getLayers(String texture, int light) {& H7 `) o' @. t0 b/ g
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));3 ~; `% c' k2 n; P
- }
4 z- n+ p h! ~* h
0 d0 D$ Q% `$ d7 q. p8 M* c4 d- private RenderType getLightTexture(ResourceLocation texture) {
6 u) c: H8 S" V7 V/ ?, |1 ~ - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
& u- d* R) f; L/ |# c- ` - }
1 k; a2 ?( M/ J+ \# }+ o - $ c. I4 D g7 I
- private RenderType getTexture(ResourceLocation texture) {
! o: F* z: F" F& f- U9 F5 o2 q - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
/ ^, B. ?7 ], h+ P' X% g - }
* [2 }: M# ]6 i8 ^ - 8 ~4 t) @. }# ~
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {. F( K, l# V1 W: _# f
- if (cache.containsKey(identifier)) {2 j& ~/ ]; g4 \! [# i Q" ?
- return cache.get(identifier);
* \: f1 m3 @# T3 h - } else {
+ q( C$ j& q, J8 |; k - final RenderType renderLayer = supplier.get();
! [$ l; _1 ~( _* d+ A. ~1 [ - cache.put(identifier, renderLayer);) c8 K' x1 m! K% {+ ]) T
- return renderLayer;
% S3 M$ Q' `. n+ b6 ~( |) c( |* Q - }# D! y. g* ~+ ]2 e) p! k7 f
- }$ Y7 B E9 V. E8 ]2 E3 i3 d
- }
复制代码 |
|