|
|
$ S8 g6 j- B% V1 h+ b
行,这个怎么样
8 X# v/ |- _# _9 ?8 l- B$ n- package com.xhg78999.mtrfac.render;' ~- @4 b1 ?4 g: l* k
4 Q( d- ?& H. h- import com.mojang.blaze3d.vertex.PoseStack;! g+ y4 C5 l) {0 d! J# E. ^
- import com.mojang.blaze3d.vertex.VertexConsumer;) O; c1 n, c7 G" I0 C) b
- import net.minecraft.client.renderer.RenderType;4 O9 Z3 j' y6 v
- import net.minecraft.resources.ResourceLocation;0 [5 N6 A' a. E x2 ~
2 }8 H, O+ t$ H2 w( A x" x. r- import java.util.*;
* t- o; N5 c0 K) m$ {' ^ - - _1 i9 B) u a0 K. q# r$ y
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
: t* |# T( P* B+ S$ r
. O% _6 M, b) N: J5 s# l- public class LineRender{* t f9 Y1 J: A6 R( k" r
- private final PoseStack pose;+ J0 Y; t4 H/ H, X2 {/ ~$ C6 K
- private final MultiBufferSource source;
9 [4 f& P- a5 Q! c; ~6 ^ - private static final Map<String, RenderType> CACHE_A = new HashMap<>();9 c C( t$ c6 l& r9 \. l
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();. }9 `$ y9 d3 l6 j! f6 ^+ [
& k( Z: W: A ~% v
3 b! ?) q. G8 r( P* x3 c- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){" D3 |2 X( y1 |, {
- if(x1 == x2 && y1 == y2 && z1 == z2){
+ D, J0 }8 \, n2 [2 t0 k - return;6 ]' ~% V# U& ?/ v+ m& A& L7 x& ^
- }
: h2 z. y5 N& {+ X9 @1 | - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
: B$ [, X) i j* Y$ n0 g1 C- n% v - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
" P9 [! i+ U' R) R5 @% K$ }* T2 R - }
7 W: F) O* D9 i) \/ u - pose.pushPose();* g, D" v" |( _ x1 p
- final int newLight = convertLight(6);
1 O4 n- {8 T/ Z* R8 W$ i+ ?- M - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
& \, H% F( }- y/ l, l v) B - final float lineHeightSmall = (y2 - y1);) B1 e6 A/ E) p
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);, g$ C" ?" w1 r
- pose.popPose();& i- R0 @' ]* X2 ^
- }/ d$ r5 o' ]) R h
/ G0 [& k0 y: [( Y- private RenderType getLayers(String texture, int light) {
6 k* L4 }) k. d+ f1 U - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));2 l, {/ y# K/ g1 @+ A! d' X
- }
; @! u% X x* \. j
8 L& |+ F( i ^- ?9 S2 a3 U- private RenderType getLightTexture(ResourceLocation texture) {
1 B2 f. S0 q" W$ i( K - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);: Q( F9 ]) k4 L/ G' J3 @
- }
! t( m/ j! E: ~# e' a: d - : p2 N' e2 }3 T# S5 b1 V: H
- private RenderType getTexture(ResourceLocation texture) {3 u; P/ D. V+ M1 l% }
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
' ]7 h! D+ c; g, f - } J) ~6 n6 w5 v& O3 r
8 t+ U) k9 U6 q, W: H$ S- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {* l; O, p. J* i1 l. E- {3 y
- if (cache.containsKey(identifier)) {- u7 A# a, v! w, h
- return cache.get(identifier);8 l. m* {6 J+ Y
- } else {+ B& R6 k0 F# B
- final RenderType renderLayer = supplier.get();( i6 p- S* S/ E% _. l% e7 q- \
- cache.put(identifier, renderLayer);
1 Z2 i, A. q1 q! S/ h' N - return renderLayer;
+ m$ v5 W3 ?1 O - }" Y3 b8 u3 q8 L" u9 J
- }( }, @" E. _9 v o$ \: H
- }
复制代码 |
|