|
|
3 A |, m7 S9 z/ T行,这个怎么样: k! y5 f3 t2 { R
- package com.xhg78999.mtrfac.render;
- V0 \# a5 s- V; Y' x/ D' { - 6 Z" n2 r* T o+ w
- import com.mojang.blaze3d.vertex.PoseStack;
2 R! p' }7 s( [/ H, Z8 A! q# ~# D - import com.mojang.blaze3d.vertex.VertexConsumer;
u: S" i* ^2 x - import net.minecraft.client.renderer.RenderType;9 S" s' A' n% \
- import net.minecraft.resources.ResourceLocation;
7 K- X6 D2 g6 l A, h1 [) z
6 W9 W5 t/ Q1 U" K. n$ C- import java.util.*;; W: R! T- [$ U5 ^" Y- Q* u* ?+ E
4 i4 B" Q! r$ g* C6 q2 ~2 |- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
6 Y8 ~3 o5 V+ I
$ p9 h" C- F/ {; J- H# Q9 }- public class LineRender{
/ e0 `* p/ ~* e6 @4 d - private final PoseStack pose;2 a9 X/ y* m& s6 A5 \5 Y
- private final MultiBufferSource source;: p, c+ D- W' z. J# y" I
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
% q* z9 \: P1 N. `- z7 y" Y; h - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();7 p$ c( x8 Q K
: N6 ^+ E7 C% r. X+ j+ g% h9 H
/ u+ _7 l8 i# s( b- I8 t* \- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
, f& C' \1 e3 X' K+ ^ - if(x1 == x2 && y1 == y2 && z1 == z2){, ^' o4 f* B2 u2 R
- return;, V7 o0 {+ q# `3 j9 _; b+ C
- }, z! I8 j0 J1 j+ X P: k2 j
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){3 d0 a- l) H( s) G6 E* L
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");2 k) E( G' S+ ~& m
- }( H6 w3 x' G3 e4 ]6 P6 ^
- pose.pushPose();, a8 _! _6 i+ o
- final int newLight = convertLight(6);
4 W, H' G1 L1 S" ? - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
' G. h7 F: X. f& |* K - final float lineHeightSmall = (y2 - y1);
2 T- f% y$ {6 N8 u - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);2 t5 }1 i4 p' p5 K- G7 t
- pose.popPose();: m* c" Y9 s9 L; y
- }
1 I a3 g% c- B" a
+ d' m' T; Z* K7 i. l6 x- private RenderType getLayers(String texture, int light) {
% Y; o* O5 [4 Q; I; s - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
. l1 M, {) A3 o8 ?: _( ^/ |. Q* Z - }3 |5 v% Y% H2 u) k; @+ k- Q
- - J+ L9 {5 X( u* i' @9 ^8 y
- private RenderType getLightTexture(ResourceLocation texture) {% K3 s" R L' P- b9 [$ C6 Z# C
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);( H u" o q+ c4 K: s/ G
- }3 S. ^3 X `! ? P7 l. \" G8 b5 l
/ m% X' a: q: l3 K" B( `* t- private RenderType getTexture(ResourceLocation texture) {
: ~: d. S2 l) [4 i$ C9 a - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
2 J, J! c- n* g b) i - }1 v% a+ D5 b0 k6 u+ [0 D* z) }, v- X
- ) T1 {, G( J6 V0 y( z2 D7 P" y- B
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {' n4 ^' J$ F2 E! ^. p+ x
- if (cache.containsKey(identifier)) {. u9 C+ Z- v% t% d: o* h
- return cache.get(identifier);
0 a3 Q* ^" l. C2 c# ? - } else {. Y% [! v6 y1 q& M& |2 Q7 M! ^; i z
- final RenderType renderLayer = supplier.get();
0 Q$ s$ V1 [+ U, F9 y1 I* m - cache.put(identifier, renderLayer);
- `" j6 s4 X! H/ u2 A$ ~ - return renderLayer;
; c( L. s7 I+ ^0 _- V, O( h - }
( W* D9 E s: ?& K - }
! {$ J) u# e' x- B, m7 l - }
复制代码 |
|