|
|
! F- I! k& k" K* r+ n
行,这个怎么样
5 n5 [5 D+ e8 V2 o- package com.xhg78999.mtrfac.render;
+ E# K d, a, b - # |9 v+ z# e' R% w4 F
- import com.mojang.blaze3d.vertex.PoseStack;+ W: | G4 a+ t7 q- a4 ~6 ` u6 X
- import com.mojang.blaze3d.vertex.VertexConsumer;
" e1 l* g. Q* G1 A0 V - import net.minecraft.client.renderer.RenderType;2 }( e8 a& Z* d
- import net.minecraft.resources.ResourceLocation;. z# @, x; v& [( v# R
- a& f* }5 x3 a- import java.util.*;
. H, p$ I7 S% ~. m# K8 y# k - , h& F4 @2 `. W. X) @# E& G
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(% w* ?' q5 e( Q! [ T
1 q8 { _9 e8 J M9 e- i7 {- public class LineRender{3 v. u* v# `7 q- C% v
- private final PoseStack pose;
% q+ H5 l$ L$ Y# Z; I - private final MultiBufferSource source;8 X6 x/ O! ` }' g( s
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
" _2 N, X& M7 d- |4 r4 D$ E - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();' ]! I+ J& w, u1 E
- ( q5 X* d+ _4 a, ~$ s+ x
- 4 X( O, X( w2 T$ M* x$ J2 @3 b
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
' i: J1 }+ \- A! H - if(x1 == x2 && y1 == y2 && z1 == z2){$ p' J% Z9 ?3 I, |9 f1 C J9 q/ [3 E
- return;
6 V6 ?- g: @# A, X' U: L) c- l - }
) S3 L$ F- y: B7 G" J: B0 z - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
M2 p2 a: C5 K6 J X2 J - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
( y- U0 U |& T% b, B7 M8 i; W; { - }
7 _( e; h7 M. W" Q& v4 V6 ^ - pose.pushPose();
: D3 f3 ^% J& E% \ - final int newLight = convertLight(6);
! B* l5 x6 D. n, g+ S# f - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
* M, B3 ^5 [: O) G - final float lineHeightSmall = (y2 - y1);
& W7 S3 h, C% M$ C1 h - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);, z# D* v- @3 ?4 W
- pose.popPose();9 j; I) i% _: X
- }% D0 G4 [ [7 P% L- E
- 8 F0 ~" x3 V$ _/ X$ H1 ~ i& P) W
- private RenderType getLayers(String texture, int light) {2 } A, R3 `! ^
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));- a C9 x- e0 u
- }! \/ i! ~0 v; p! _
' y9 t& b' p3 J: C- private RenderType getLightTexture(ResourceLocation texture) {7 G* b s% z; J3 z9 Q
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);+ {9 C2 Y8 ^1 O7 ]$ t/ [
- }5 s% ` H$ {) Z! C6 V6 o
- & Q! |, I6 d9 n+ D
- private RenderType getTexture(ResourceLocation texture) {, N: c( C# U0 u- b7 S
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
. g7 v! M9 ]8 @. q/ Y3 _ - }
) ?6 ]4 V& s- x7 h
0 L* V: g5 W- i- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {& w5 l, G8 A: N7 j5 N$ y
- if (cache.containsKey(identifier)) {* A8 Y# l6 w+ s' P& z) M
- return cache.get(identifier); E) h6 s* _& T) h! q
- } else {
5 `& x6 r6 F# | - final RenderType renderLayer = supplier.get();
0 b b& n) c( O d5 o4 v/ t - cache.put(identifier, renderLayer);
# I; [2 B6 ]/ ^9 h8 E$ p9 ] - return renderLayer;' P- e8 o- k) ^ R
- }
+ \6 Z: T2 S' c9 t/ n - }
; C6 ~4 I9 X( k4 ?6 _" y2 S! m' y - }
复制代码 |
|