|
|
& p2 g+ K9 H2 v, Q7 G3 E U行,这个怎么样
% A! @8 T; m7 _% w5 [- package com.xhg78999.mtrfac.render;
( `( s3 Y8 G( @- o - * d+ H3 W& U/ b( F$ {0 e# W
- import com.mojang.blaze3d.vertex.PoseStack;& H7 F) o* D; ~. [5 u' D- I0 m& h* g
- import com.mojang.blaze3d.vertex.VertexConsumer;
' g3 m% o/ w: S5 s - import net.minecraft.client.renderer.RenderType;
4 Q n% i( Z4 P* m$ k - import net.minecraft.resources.ResourceLocation;
/ Z' M. c: v6 U# y7 X; r! \/ M
# K6 W8 K, b4 N2 h- import java.util.*;
; g- G% d# Z1 a+ v9 I# F - 1 k$ q, v6 m6 E) c+ J5 a& T
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(4 Y1 Y/ ]6 d# A' O
- ^' W1 n# b `& ^, Y( b( P/ C
- public class LineRender{- _8 {7 T& |6 x% `! x) w
- private final PoseStack pose;
) k; g2 @* D3 \) T& e8 Q8 Q; `8 J& L - private final MultiBufferSource source;
0 w# S \3 E! y. }2 l - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
& d: w! _/ X+ o, O! q, s - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
$ {! q/ O- K4 z# c - # D C3 u$ s4 J0 B" _! t# l1 W! e
+ P' A$ P% K4 @# J4 h- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){; A% p$ ?- {5 l/ Q. h7 p) V: K
- if(x1 == x2 && y1 == y2 && z1 == z2){3 P8 [9 d, V9 N( M' h
- return;
9 ]. h/ S! \" S7 R# N6 [* T# E - }
: I2 ~1 h' d4 O5 L; X# l7 g - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){- G0 `8 S( X v8 { T& [
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");3 S4 ^' E- c0 h
- }
& V( k+ o9 q# Y+ b( l. t$ P - pose.pushPose();
5 N$ Q$ R* s$ }7 p# Y6 x9 G6 n" I. f0 | - final int newLight = convertLight(6);6 r. h$ N7 u1 X3 Z9 ^6 ~6 f
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));6 ~4 }; Y' |' e8 U$ G1 t7 Z- G; U
- final float lineHeightSmall = (y2 - y1);
$ U, K( A9 |; D+ R" I- F9 f - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
c) }5 W$ ^! c$ s5 ] - pose.popPose();* O& |1 d9 g' z3 n% }5 g
- }* D8 |& \* r& T9 m* [
F b I g/ C9 K9 R/ Y6 `9 K- private RenderType getLayers(String texture, int light) {4 t# r# M! Q( S2 E' d
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));/ N1 ~( ]6 h: p9 q2 ?4 [' Q
- }
) d2 h& D/ }% {$ C& ~' t
) J, E3 T; m" U% [' p- private RenderType getLightTexture(ResourceLocation texture) {
' k' ^" M9 P6 u; [ - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);# L# H- u0 M) U7 Y
- }
. p& O; T& F @; z1 [# N
( [5 H" ]3 }* o4 f. L- private RenderType getTexture(ResourceLocation texture) {
+ {, t( z# \7 K7 o - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
% V! i: {5 m9 m; u. u3 \ - }% r( {" o$ E0 X4 ?+ {
- 7 K0 n' K. ^. b( ?8 Q/ ~8 k- D$ `
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {( C0 F" T" u/ T" u1 [
- if (cache.containsKey(identifier)) {. I: D J! r& U# A' |3 R
- return cache.get(identifier);1 d0 p- }3 Z3 U
- } else {6 ` S5 d5 q6 ^% N
- final RenderType renderLayer = supplier.get();
' _- H" b; C0 o0 L* E - cache.put(identifier, renderLayer);
' P8 r& B2 u8 o% e! J - return renderLayer;
% u6 Y. A d6 ~4 p u8 ^% ~# p! g - } A- c2 k& _. [+ ^
- }
0 l* i. r3 h$ b1 K& I - }
复制代码 |
|