|
|
9 O6 ? k0 T! \" [6 ~& X5 c' [
行,这个怎么样1 E! u0 M7 Z0 j- ^# f+ J6 R _
- package com.xhg78999.mtrfac.render;1 R; P% w& q) A
4 S9 j* B! {# m) B! @* G/ P/ w Y- import com.mojang.blaze3d.vertex.PoseStack;: H' s9 U& p4 v
- import com.mojang.blaze3d.vertex.VertexConsumer;
! A) b; E3 D" p5 W - import net.minecraft.client.renderer.RenderType;
3 u9 {' ^4 p" y - import net.minecraft.resources.ResourceLocation;% W2 F% p+ s" [- |
- 0 D$ l/ O! b3 `0 R$ w% V
- import java.util.*;
f7 x9 L0 j" ~* d8 C! l3 V S - 7 c% T8 J3 Z% H$ E2 C1 |- G
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(! o$ n; F( _; \' M( M$ ~( @
/ [, ~. ~& |: p- public class LineRender{" b6 J2 {$ y! h6 s
- private final PoseStack pose;
) V3 M: t" s; h1 l. M0 H - private final MultiBufferSource source;+ f/ i; Y9 ^8 `+ v$ o/ Z. j
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
7 o. k& U T1 R1 k, I- z - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();! ?& Y" M' A3 y; m( I- A8 t! `( F
9 }6 b4 ~- [& k( g
2 z) T- Z# [& q$ m* F- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
$ o% w' I0 g* j - if(x1 == x2 && y1 == y2 && z1 == z2){
8 e8 C& ^; l4 q1 k; ? - return;
* d1 Z( ` C0 R' U8 r# f+ k - }
# E; a# I' A8 x8 G! X; H! ~ - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
; J; B0 L- C. l" f. g6 g - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");. [+ Q; s* G7 [# R/ P# n1 x* \
- }9 h" e3 S& b9 l; G, d# A
- pose.pushPose();
% p9 P! d9 m* ]4 M! k1 o9 M - final int newLight = convertLight(6);
; X ~4 H, @& r0 Z0 ]# ~- z! i - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false)); t' u+ s% n/ |% l2 T
- final float lineHeightSmall = (y2 - y1);
9 a& t5 P% |8 w- y) ~' P. G7 J - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
$ ~3 |) G$ T0 m) b1 q# L5 ` - pose.popPose();0 ?0 C" j4 [! A# L0 J! t
- }
6 j: I2 W0 E& k; u: L
. C$ L) g! [) R1 `$ W+ ]0 f- n- private RenderType getLayers(String texture, int light) {& M: n# w4 P2 k) w# A% k1 M ]
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
8 }1 r& n& l. \ - }
+ ?$ I8 B. |8 \) V/ x - % p+ k8 g: C' F9 q8 ?7 D
- private RenderType getLightTexture(ResourceLocation texture) {4 C3 H' y% z- s# d, Y: [& B8 u
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);6 N6 h. G: H: W4 m! {
- }
7 C3 \1 ]% y6 k* P* s, D Q$ ` - : V* r+ X. c8 D k, g% u
- private RenderType getTexture(ResourceLocation texture) {
9 A& \: n+ F$ `3 V! H - return this.cache(texture, () -> entityCutout(texture), CACHE_B);& [7 J1 z" I* n$ B* {! m( f% u% i
- }
" O: r1 {: z _( W: V
, [5 N$ i, T" ?6 ^$ A0 \- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {. g1 J$ ~; n/ E5 ^. l" ?6 c
- if (cache.containsKey(identifier)) {
* o6 H" E3 n; a! r0 g4 ~ - return cache.get(identifier);! R+ _0 F+ t, f/ p
- } else {
# F% B3 {) o5 y% X, e - final RenderType renderLayer = supplier.get();# v0 y- W( [" n
- cache.put(identifier, renderLayer);
- I! b6 g/ R- m- V - return renderLayer;% J, v3 U }0 V9 b* I/ w/ T: y
- }
: b: N# W9 B, w& ^# d& u - }
- K% Q! w% t( o$ G0 W6 u0 | - }
复制代码 |
|