|
|
/ i$ W% f, ^: |# o0 m5 i
行,这个怎么样
) u# M# ]$ `& K- ]7 u# q- package com.xhg78999.mtrfac.render;
8 T2 t8 e4 |4 k9 q7 U- }: K6 q2 C% h3 B - + B8 x' G6 r) l* v9 v
- import com.mojang.blaze3d.vertex.PoseStack;
, F: m B% ^ L4 e4 M5 B Y - import com.mojang.blaze3d.vertex.VertexConsumer;
0 R* `7 |" U& T; G" X' ^% J! O - import net.minecraft.client.renderer.RenderType;
; z. r: R6 v) v8 n1 d- V) { - import net.minecraft.resources.ResourceLocation;
; a7 s9 s! t/ Q. O
1 P4 `' ?* F4 l3 Y5 x- import java.util.*;- x0 M7 P8 ], e6 B9 y! p
- " \3 {( x1 }7 q2 L6 |$ U ]" ]
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(# J4 a I9 Q% _ m
8 c& _7 l$ P+ ~2 V) c- public class LineRender{
4 A' e- e6 z" g5 W0 ]2 t - private final PoseStack pose;7 T& t5 K e3 E+ [7 O
- private final MultiBufferSource source;
- ?. D4 y- E; L, _( V( J* ^ - private static final Map<String, RenderType> CACHE_A = new HashMap<>();7 b5 s5 R K# t- l/ Y' j+ e
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
$ ^; n. V' s5 S* Y" a! @3 [
C4 k' E" D5 B6 w! A- ) }# L! E0 Z( T; E% r' D% F
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
% j: ^# c& R5 m5 o+ Q - if(x1 == x2 && y1 == y2 && z1 == z2){
+ M5 @7 C. x# ]5 {5 U! h6 n - return;3 d, ?( K$ J' q& Y- I8 A2 H% H
- }; ?4 G y6 W$ O! ]+ ]0 E# `
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){' E W7 H+ f8 [4 s' [
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");4 X% a: m* W' C- r' d" r
- }
4 k7 ?' R* L: W" W/ J( F - pose.pushPose();8 f+ n$ H# F4 k
- final int newLight = convertLight(6);
3 y, X$ L2 s+ b3 Q5 g( p" E2 y - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
, M# y, P7 ^5 \ C - final float lineHeightSmall = (y2 - y1);# Y/ c3 d. V" t- S* ^7 B
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
( W w: k' S- H - pose.popPose();" `. ~ D& R- @2 H- G% H/ y
- }! H2 S9 M# [/ d. G
7 V- b+ t& C8 r. Q" N6 [- private RenderType getLayers(String texture, int light) {4 G o6 q$ O3 g7 j
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
7 n7 T( D" m( p2 a - }* T# q* n& q; _8 q% ^' e/ s4 q- W
- 7 n/ J* x7 _# _6 B' i' H
- private RenderType getLightTexture(ResourceLocation texture) {
: f" |6 F# f9 b P - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);/ q) W; U& D) C4 z+ s
- }
! B# a6 f& s ^" q& { ]/ d# [1 N - * k- ` c) I& U! ?9 G8 w6 e: _
- private RenderType getTexture(ResourceLocation texture) {
) G9 F4 J0 {2 M! q; {* v - return this.cache(texture, () -> entityCutout(texture), CACHE_B);0 y) K4 U* t& b8 n7 G( O8 r
- }2 F2 t8 m0 p* _% _: [# r+ {
- ( q! d# ]% Q3 Q5 f, [
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {. |4 f6 y' y, t
- if (cache.containsKey(identifier)) {$ z: v5 |6 ] H l% X
- return cache.get(identifier);
k; k2 \. h P) U1 d% d( P - } else {
; k: F3 H- y0 \ - final RenderType renderLayer = supplier.get();2 B* Z: {* o7 q }" P/ C( P
- cache.put(identifier, renderLayer);" T T7 p0 o# R5 N+ u% g7 [, u
- return renderLayer;" c8 c9 v- v1 p- n% W
- }& v$ I( m& r$ c' b
- }$ P2 `0 V/ n h" y( g3 m5 q* i" Z( n& z
- }
复制代码 |
|