|
|
7 F- ?7 m+ f; z
行,这个怎么样% P: ?$ Y5 ^/ _- P5 H
- package com.xhg78999.mtrfac.render;* g' H( ?! k8 \" |
- 9 a7 f/ A9 t( r1 Z/ ]
- import com.mojang.blaze3d.vertex.PoseStack;
2 N9 K5 E. o: x - import com.mojang.blaze3d.vertex.VertexConsumer;
1 h I* ^% h' z* ~: R) N6 D( |+ q - import net.minecraft.client.renderer.RenderType;
" r! Z( V3 Q# [" _) Y/ T9 A - import net.minecraft.resources.ResourceLocation;
4 \5 v: L7 R- L* `" c
7 [5 b. I7 D3 m7 R, m( M5 p- import java.util.*;
; T# P) |$ }8 ~ - 0 q/ b! l5 l8 A# u* M
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
& }" J6 L4 O- P+ @8 u a
9 y8 j2 {' h1 u5 H! c$ c/ h- public class LineRender{
% A( d; e3 [+ ^ - private final PoseStack pose;. C2 k8 z8 R1 h+ n2 S8 A9 F6 c
- private final MultiBufferSource source;6 c& r( q/ F# {" x Z
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();0 m4 j$ D2 \. x$ b, |2 v6 R
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();5 b4 X9 m$ W# o% p% E$ B3 B! C( _
- 2 U( v [' S1 L2 R
: g* e9 A A/ n- @/ t: G: X- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){/ F+ V5 m$ T% L6 [& r% t2 v
- if(x1 == x2 && y1 == y2 && z1 == z2){
& J, t% C7 z0 X: d - return;5 [ j: f( D$ H$ k
- }: Y+ S* m1 h# V9 ^
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
) c! R- u" C1 x/ t. p3 V' X - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
8 T$ j1 j! P7 C4 F! Q) j - }9 z, L- e0 R. g) I& z/ V" Z5 _
- pose.pushPose();1 B2 l* p) X4 i
- final int newLight = convertLight(6);
! |$ w5 ^6 Q$ ]: V9 g - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
( D3 _1 p" z/ U8 y+ G/ n, W - final float lineHeightSmall = (y2 - y1);
7 l! y9 @0 Q8 Q4 N( h - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
# h* \( |( t: x( Y# M4 i - pose.popPose();
5 P- @6 Q/ {; U; T4 f - }% Y( v+ s/ { W0 m# Z- h2 H. [, m
- 2 B% l" E% [- b) e% ]
- private RenderType getLayers(String texture, int light) {
: C# H1 ?4 ?% [ - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
5 L' v( ]) R5 Q1 B7 N0 e - }
: t$ ~! k/ {4 ^2 _5 k - ) c; R' B: N0 [( `
- private RenderType getLightTexture(ResourceLocation texture) {1 ?" p( U- t% l" B; B' i
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
7 Q. Q6 _6 ?9 u- s0 L1 m/ B - }6 A4 H: A7 {9 x e0 a8 V
- + o# n# o& V5 p9 a
- private RenderType getTexture(ResourceLocation texture) {
2 v7 c% C8 C+ G/ f8 |& w- Q: _ - return this.cache(texture, () -> entityCutout(texture), CACHE_B);% a. b& m" h0 [
- }7 j* z" q% t. o# e: x4 G0 i7 P) }7 ~
Y" M* x7 }$ |$ M* t( t0 K- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
+ o" H+ x" d* t5 E - if (cache.containsKey(identifier)) {, N6 k" V7 I( w! z" G
- return cache.get(identifier);
% C4 t7 q2 {7 W" t - } else {7 I1 a9 C" U( c$ `' g; m
- final RenderType renderLayer = supplier.get();
9 P: |9 g$ z Y' D0 F- _! U - cache.put(identifier, renderLayer);2 _& f% t# G' h% P0 p) @+ L
- return renderLayer;
9 ~& m: y2 T/ q6 E% s - }6 t4 N' ~, M, ]; H
- }
; w& @2 c2 Y2 ~) l; J - }
复制代码 |
|