|
|
$ J3 i& U- B' v' M+ j行,这个怎么样
1 y: b7 J. m, T" H- package com.xhg78999.mtrfac.render;
J1 M" q; u& n* ~5 ~ - 7 p1 w6 ~7 i8 e' p1 U
- import com.mojang.blaze3d.vertex.PoseStack;. ~& P% ~) ~( {& L# {/ [; W: O
- import com.mojang.blaze3d.vertex.VertexConsumer;8 i+ a' H$ E$ J. e1 H" z/ J
- import net.minecraft.client.renderer.RenderType;
6 c5 _5 e. a; a0 u. B j$ o x8 A - import net.minecraft.resources.ResourceLocation;- i5 d6 k% C) n1 K2 g
- ' R: `+ |- k d& r
- import java.util.*;
9 Y F- c7 t* d1 z' P% p3 Z
& c- e7 ?" q! b" M2 `5 r) T* i- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
# d; I J" d h - ' ~ ]' }8 B" Z2 m+ D: X( t9 }
- public class LineRender{
' ^ }5 d- j) `2 D& d' p - private final PoseStack pose;
- v! X7 T. s& s w7 h% u2 { - private final MultiBufferSource source;/ C2 A! w& H2 f+ D2 R
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
3 ?$ p2 x4 _/ ?: ~3 D3 }4 s" T - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();( ~8 v8 S. w2 ^8 {
- : L+ s4 {, I, J
- ' t8 x7 ^! S/ r* B
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){2 G& D# R$ w; r" h+ c. Z
- if(x1 == x2 && y1 == y2 && z1 == z2){
; t1 g8 ^( [" t1 E! A: Q - return;
- a5 J; O' [- R- O% w - }
* f3 s) Q5 p# {5 ]4 B2 K7 Q8 v - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
' c# u0 C( W3 }, a K - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
* ]1 [. u! s5 D4 B h# z - }
- |, j d3 I9 E n- N" s2 C - pose.pushPose();' [. }% A- m5 E4 T% J2 G# F
- final int newLight = convertLight(6);
) g) t& ^6 c8 D# { - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));$ P* u. p4 d3 S. G8 ~$ s- I2 D
- final float lineHeightSmall = (y2 - y1);+ h+ b, N ~+ }. x$ G; S
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);% u2 o _7 A( R; x9 {
- pose.popPose();) \5 U: P: o$ T; s
- }
2 h( J" e* E8 |& d4 I" H1 @
) u0 C M2 F+ d, q- private RenderType getLayers(String texture, int light) {
. D9 E8 @) S/ _( @ - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));4 z1 v5 w: p1 j0 ~3 X
- }
+ e! l. O; T+ u* U( R - 7 f* z7 b/ H m
- private RenderType getLightTexture(ResourceLocation texture) {9 F y4 h( }; N) C' B P& N
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);4 a. p# M8 ~$ E& p; c% L; U- p
- } S! S1 d. |/ X% @" a2 ~
5 m( ]2 S. ?) Y1 o7 w1 C% D' W' e+ q( z- private RenderType getTexture(ResourceLocation texture) {
* N0 Y/ m! z0 Q7 g5 v' R - return this.cache(texture, () -> entityCutout(texture), CACHE_B);( S' A1 C' p1 W5 W. H* t4 C$ f
- }
% h) b8 T6 C* I( Y! J' z# G6 ?' Q
" h( l- G \/ a' b( G& ]4 Z! A6 w- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
4 a, E7 |& E4 Y) F& P* e- { - if (cache.containsKey(identifier)) { y" Y- L0 @& a0 N, b+ y D
- return cache.get(identifier);: H6 e" J" {4 ?. V( w: P
- } else {
- D8 }2 b/ r6 q2 R( t. J8 k - final RenderType renderLayer = supplier.get();
, u/ Y; q+ k( u8 S8 {3 v - cache.put(identifier, renderLayer);- L3 g4 O6 U% S/ @0 V+ i) y9 |
- return renderLayer;0 U2 {0 U6 e, g8 P8 J
- }
7 Y& N; j; ?1 H - }+ b e2 P& F9 F. j8 s- a# K; L% [
- }
复制代码 |
|