|
|
" q! ^7 v e7 D" `& n. c. Q
行,这个怎么样
, P* H- d/ G- ~0 d- package com.xhg78999.mtrfac.render;5 r2 a N9 f8 S, C& w
- 6 o2 D5 b9 Z! I E1 A0 m' J
- import com.mojang.blaze3d.vertex.PoseStack;: [% f8 q$ v9 Z% Z
- import com.mojang.blaze3d.vertex.VertexConsumer;
1 o% G" h [2 s+ H/ a9 \( A - import net.minecraft.client.renderer.RenderType;9 w) d+ ?$ K3 u- m2 X( k
- import net.minecraft.resources.ResourceLocation;4 j( o* G3 w' Q, |! J
- 9 X! [. _+ m' q; \' b
- import java.util.*;
+ h7 Y6 v7 y ^ c, d# e
4 Z$ b' v5 S a. \! S9 B% F% v- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(# X& ]) N8 Z8 l1 V0 v' e4 B
- 4 O9 `, d/ R. | k- [" R; N7 x0 w
- public class LineRender{
. H3 X: ^+ J. W# m0 \ F. [) V3 H1 X - private final PoseStack pose;
$ j( R/ }0 F& A3 a' f - private final MultiBufferSource source;: i5 f: Z8 N6 Y+ Q% c* \/ @
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
7 y8 @6 [0 n3 n/ b1 l2 u - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
9 m4 b, X2 V6 l9 q r - , Z/ \! d/ g0 n4 n- _, ]; X3 J
, J% h% l$ q9 ~( _- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){8 Z: w$ Y% x9 ^2 X8 J2 J7 Z
- if(x1 == x2 && y1 == y2 && z1 == z2){
1 w& W8 [0 w |0 { - return;
1 o% p' d" }& u" |1 T - }8 {: }) [1 N. L7 X( y4 m% Q
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){3 C/ e9 t. F0 o# }; b& u! \
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");7 t7 Y3 t- D$ |0 G1 \
- }8 y; ?) j6 M9 b- z3 k9 n- H
- pose.pushPose();
9 c' A# z4 C- l& }8 `) n - final int newLight = convertLight(6);, z7 N G3 w& j3 h! F
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));) A$ P% T7 V* @# I/ T4 x1 l
- final float lineHeightSmall = (y2 - y1);
: t W4 b2 F# f0 G) U. M; x3 j - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);" ^7 o N# p4 S' H9 W
- pose.popPose();
$ b# k) W7 x8 y9 c8 `6 r5 w# a - }2 [3 s5 ?9 R3 U/ i0 v
& U- K: M( l% v, e9 u. p$ G- private RenderType getLayers(String texture, int light) {
1 R1 W$ A; z2 g2 A, W% t - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
- c2 Q9 r/ y% o: \ - }
/ y) s7 n, K# F7 _0 {/ I2 Z7 W
# ~5 b- }' {6 b9 R! @' `- private RenderType getLightTexture(ResourceLocation texture) {; }. a3 j" w7 Q q% k& e
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);5 k" t& C8 ^: v
- }$ F# G# P6 n& Q1 a; W, h; o
; Z7 U \* R" E; e6 |& A5 o5 g* j- private RenderType getTexture(ResourceLocation texture) {
4 i( X: J4 [& U4 e X( K - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
7 @7 @9 w, ^0 u+ r( O6 o8 P - }1 G$ V7 y5 x" c3 A$ d' S4 O
- # j; x4 `1 {! n
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
, Y) s2 U# S" R$ P+ o - if (cache.containsKey(identifier)) {
; \& k( t/ s9 U0 R; k - return cache.get(identifier);0 k0 Z, I1 _! ~5 s* `$ V
- } else {
4 C- b* d A8 r; r9 R3 H3 n - final RenderType renderLayer = supplier.get();
`' ^& E# U5 D* p - cache.put(identifier, renderLayer);
$ V6 r4 [! M8 T/ _# q# I - return renderLayer;
: r6 U) y% I; I - }
4 H" h: k( q9 L% L' ~2 o2 q2 w1 r& G7 s - }& M4 V9 H' X x/ l$ D Q7 E
- }
复制代码 |
|