|
|
( P4 E, r- F' G5 c }
行,这个怎么样
* p! M k. F' n. U% W! S4 z2 u- package com.xhg78999.mtrfac.render;. W1 `9 w0 y; A4 c( _% A- g! D
- : a) d4 G$ H; N. e" `5 `. v
- import com.mojang.blaze3d.vertex.PoseStack;, D/ Z2 N' |1 A' }1 i' | z
- import com.mojang.blaze3d.vertex.VertexConsumer;2 n3 z( ~4 L& N: B6 i2 g" \
- import net.minecraft.client.renderer.RenderType;, Z0 v n \! J; {9 H- o
- import net.minecraft.resources.ResourceLocation;+ e8 L6 z) m4 `% o4 q, \+ ^- ~& u
- ; L; `* U5 O1 [9 K; K* E& J0 v
- import java.util.*;
- n8 M- w+ p. ?0 n5 U/ `- y/ X7 M$ G
/ w$ G% Y$ e; }6 `2 A' K) o2 R- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(: T( h' H1 K6 D9 o; M9 T+ ~7 c0 g6 Z
( C/ R3 K2 l1 Y: f8 H' `# U- public class LineRender{9 \: }5 k8 t9 M2 r. Q
- private final PoseStack pose;: |& I+ U: K7 L7 x S
- private final MultiBufferSource source;" [/ ]4 H+ ?4 s+ c. x0 i
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
1 O" @/ i- X- a - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();2 ~8 @/ B! b" L7 @
$ w5 ]$ g5 ^; g) i5 n
2 T* l ~: `9 `; s- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){- V+ \- ~( R' M* Z
- if(x1 == x2 && y1 == y2 && z1 == z2){
! Y1 g" q" M* l5 [ - return;
9 }: C, j$ Z# ]0 o5 p- I0 @ - }
& E/ X0 U# j0 j7 |; w - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){- l3 |; Q# H! ]. c; O
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
. d+ T, G+ N: o - }
" P2 B. y1 J& H7 V8 _ - pose.pushPose();$ W1 D6 i/ {: @% V
- final int newLight = convertLight(6);
+ L k* u. E. l - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
% n- V2 [; D% A( S* | - final float lineHeightSmall = (y2 - y1);
; ?: g/ r* |" P6 t - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
7 [7 o$ X U8 j! a3 V - pose.popPose();
, C0 W( \4 D/ W- b' Q* @; r. U - }
: |+ ~% R8 x+ d: O
) N% ~9 a0 ]( o" ]3 [- private RenderType getLayers(String texture, int light) {
8 F' I: ^4 x. t L* x* [1 x& I* i `! J - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
. X5 l( N" E# F1 { - }
+ Y" Z7 \ W5 j6 D: ~. a3 L - , ?6 `% y9 h" h# o1 f! a
- private RenderType getLightTexture(ResourceLocation texture) {+ A& S; u: h8 T4 N: v! j4 y0 d
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);$ a5 L# h* t& J$ K9 y8 h
- }1 a6 u5 _* {+ O2 G% ~! S" _
, [, W/ R) y* J( \- private RenderType getTexture(ResourceLocation texture) {: \, j: s2 | w
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
- }" v2 c3 ?9 I' c$ M - }
* C2 \/ r+ U2 R9 V E2 Q+ \5 M
, ~' M$ b3 j( }' t J# f- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
( y/ k7 }5 s0 E2 I4 z( L, _; | - if (cache.containsKey(identifier)) {
3 V' h9 i$ A/ u - return cache.get(identifier);
( U9 a1 I1 Q6 r - } else {% B8 |9 ~$ f% A. |8 d
- final RenderType renderLayer = supplier.get();! d4 A4 @- ^0 T% S% a
- cache.put(identifier, renderLayer);" X; J, d. y$ l* D3 i
- return renderLayer;
+ t& ^, ?) M5 u g& d: f - }1 m r9 X1 f2 q- ?" C& t( q
- }
% `+ R$ ~5 g, ?* g9 h( \ - }
复制代码 |
|