|
|
1 N1 H+ l) h: K5 q行,这个怎么样
! \% ~9 C3 Y; ^* K* ~- package com.xhg78999.mtrfac.render;6 y! N0 ^7 f$ M; R
- * d `5 t5 Z0 I0 U- W- ^2 p) K
- import com.mojang.blaze3d.vertex.PoseStack;7 |; ` [8 h) I: |9 J. J
- import com.mojang.blaze3d.vertex.VertexConsumer;
1 A7 A2 Z% [0 T2 R6 t - import net.minecraft.client.renderer.RenderType;
* p" ]: A ]5 p* A& Z9 D6 m2 ^ - import net.minecraft.resources.ResourceLocation;. f: G" p/ f0 J/ p5 q( y# G7 K
- + R5 [9 \0 a, S# T9 E! V% c
- import java.util.*;
6 b) b4 q, d. V, R" v - * b0 g1 a/ ~, j, ~1 ]3 {
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(' D1 P+ d. \$ b' x. P
- + Z; G, |7 c. w6 i/ @4 C( l+ l
- public class LineRender{
8 n5 m3 E2 q2 @% l. _. @9 [3 L, h - private final PoseStack pose;1 g$ I+ t; s% \# _6 A: Z
- private final MultiBufferSource source;
$ L# D$ |4 [7 T - private static final Map<String, RenderType> CACHE_A = new HashMap<>();* F+ Q& A% W |- N5 t9 J
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
; Y( H+ M0 F$ }" S' e - 4 N* e! `6 o' W g+ X0 f5 D M
' P W! W0 L" q: m0 j' k9 @- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){( E5 O4 F% S8 F; |) w
- if(x1 == x2 && y1 == y2 && z1 == z2){
8 v5 z$ K# _$ M - return;
+ g% L; ]" v' R+ Z w - }
9 V5 f) W; A9 {6 I+ Z. c0 m - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
. x) J2 K# e+ H8 C% s" a- \ - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");# ?* [- |( N7 `% S+ h
- }
' K2 w y8 j7 ?5 c - pose.pushPose();
& E1 i4 c( P# w7 Q - final int newLight = convertLight(6);
. r3 Z: B0 O+ e - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
+ L. X+ p4 b# c2 L/ Y% _ - final float lineHeightSmall = (y2 - y1);; U q1 t, r8 Y" |4 s
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
$ L+ X4 X6 `; ]5 I0 c# N0 W9 ~ - pose.popPose();; ^8 s$ [% T) {, b9 ]3 o
- }
3 I. M1 D( S8 u* P# v9 X
0 m, Z2 e2 |, V" J G. M- private RenderType getLayers(String texture, int light) {
L( Z7 Y. A* N: k0 k2 ?0 G - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));9 I% f7 M; ^2 b
- }% k) z( d* c- k |5 T
: E3 b8 G3 F, T! S0 @& W4 R- private RenderType getLightTexture(ResourceLocation texture) {/ a6 g& ~) k2 g6 A& s$ ~9 Y& i! Y
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);" _9 z( h: f. O: ^. D* L5 i
- }6 |' T& I8 V7 k" C% h* N6 t
- - w X9 q5 j" X7 c6 t6 i5 Y* H
- private RenderType getTexture(ResourceLocation texture) {
1 I4 }" f% P# E) s4 s% ` - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
, W& z8 ~! j; g1 v/ Q* v7 s# J - }
4 e; x2 U% X( F9 Z D$ ]2 E
* s: g" V2 A8 Q. f- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
& {( _7 J$ \: P! ]7 m) e - if (cache.containsKey(identifier)) {5 h a# Y( L* `
- return cache.get(identifier);
. b6 u+ t+ G5 a) ~% U - } else {
8 D. q6 }; R* n5 {: n - final RenderType renderLayer = supplier.get();) [+ l& B3 R% Z& s0 Y# o
- cache.put(identifier, renderLayer);
/ U: U, e# s( e: _; Q7 g - return renderLayer;
+ U# u* S* h9 N: y( B8 \ u3 D - }
' L* b# I0 J. @! c7 [" L: x6 @6 w( Q - }
C8 N% I; w# t6 |: x" C - }
复制代码 |
|