|
|
5 u4 [# b+ F+ ?9 l; v行,这个怎么样6 [6 Q7 G5 f7 H9 \% h
- package com.xhg78999.mtrfac.render;
, o" e; |4 S. F9 q# Q5 E% n1 {+ W3 D
; D) S) a! Q) D1 I# Q% R- import com.mojang.blaze3d.vertex.PoseStack;
. u, D4 A. k- {4 q r - import com.mojang.blaze3d.vertex.VertexConsumer;: D/ {/ M, p0 z, y7 F
- import net.minecraft.client.renderer.RenderType;( X, A+ l& ^/ _" Q3 l
- import net.minecraft.resources.ResourceLocation;
- L( }4 }; U/ K3 w# g2 f) ~/ V8 J - ) Y+ {+ A* z6 }; b- d2 m; o9 r
- import java.util.*;2 k) Q k- O2 c1 {7 T/ t
- 8 z2 N; ~' A/ L# d, ^2 z) m
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
7 Y6 C" l1 q: G; Q
- @ G) T$ M* o! Y+ }4 Z- public class LineRender{
- j' ^3 Y; X3 { - private final PoseStack pose;3 Z5 t/ |; E9 b
- private final MultiBufferSource source;/ P( X5 A# Y7 C+ L0 G6 s
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
) y9 s5 w/ {- l. g V( X - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
, d+ ~/ S L1 X8 K% h
F8 K7 Y+ _, e7 g7 h) A. E
1 w8 R5 w; q5 m0 N1 ~9 a5 U- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
/ F4 R9 s! k$ ~* ^6 D C - if(x1 == x2 && y1 == y2 && z1 == z2){
: j2 I. Y# n8 F- c: c7 y! D3 }- H1 Q - return;
. O& W3 f7 [8 Y. O) K$ I4 p - }' e) j# C* ~0 y: N+ C% ~: u+ d/ V+ p8 g
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
# R1 p5 _# U7 z; } - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
( G+ W+ |( _6 [' ^: K- ~ - }
* [" Y) ^5 d2 x1 F - pose.pushPose();
; k4 B9 \, Y. a4 }+ ?: Y3 F( z - final int newLight = convertLight(6);( b! t- I5 t% A9 y
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));" r8 z3 X' c* R& U' o% N
- final float lineHeightSmall = (y2 - y1);
0 T# v, {/ X+ O/ q - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);% {" w4 P, Y$ B3 {
- pose.popPose();
3 P% {, A3 S) J6 e( x - } M, Y; W6 [. h4 u
- + S% C: Q" l# N% ` Q
- private RenderType getLayers(String texture, int light) {
6 |5 B: Q, [' F! y6 t4 J - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
% a' D8 H, k4 E8 s - }/ W# Z% A" L4 q' @
* d% p* N! Q* I- g- private RenderType getLightTexture(ResourceLocation texture) {
* f# P' y- R* U0 a! s* w' h% Y - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
- X K" v6 ^9 ]8 o& C' S/ q - }: ?' d( `% g/ c! ^ l1 v
- , b9 |; M2 t9 h/ X; L
- private RenderType getTexture(ResourceLocation texture) {' c8 s$ X$ v: f
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);2 h, V- T9 X4 n5 B
- }
9 `* }' }% n# B7 y; y - 5 R; E2 R1 d5 H/ Z# z
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {6 I- `6 P# y2 r. Y4 v
- if (cache.containsKey(identifier)) {( W. O, W* Z& B1 O* j# F" c
- return cache.get(identifier);
( K5 u: ] X1 a/ _7 b2 X/ Y - } else {
7 u+ ~; x) w5 K - final RenderType renderLayer = supplier.get();
' [: ^# k7 y+ k - cache.put(identifier, renderLayer);
! ?+ H1 O3 Y9 I) C [ - return renderLayer;
/ l6 J$ p3 g H" E7 {. b - }% S8 C' A3 ?7 |7 h$ H% R
- }
/ A( ?9 J9 g- t1 o - }
复制代码 |
|