|
|
3 ^ P$ i4 O- Z: x2 v" u' T0 @
行,这个怎么样
/ Y. Z7 E. C8 ]; P. w s: d9 @- package com.xhg78999.mtrfac.render;
0 [' a0 N) k' _$ T3 a' \ - 8 q* a& d& v! S' c4 d6 L
- import com.mojang.blaze3d.vertex.PoseStack;/ T+ u0 C* A% i* z, `1 D* J9 |
- import com.mojang.blaze3d.vertex.VertexConsumer;
" X1 {0 U# L$ D$ K- w1 y - import net.minecraft.client.renderer.RenderType;) q5 t( c/ r6 J5 a8 @1 V$ k
- import net.minecraft.resources.ResourceLocation;, i7 M5 O& i( E/ J
5 m, C+ c& D { S" Y n4 ]- import java.util.*;
* r. u- L7 ]) I - * Q$ {/ ?1 Z( Y; G
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :() z8 B& S: y' E! E- p
- 9 V; B) p/ e3 k \9 j
- public class LineRender{
, O% M9 o# d8 v+ e - private final PoseStack pose;
- r- u2 Z7 u# N' M# m8 B4 r - private final MultiBufferSource source;4 [4 X; c C! \0 P/ O2 G
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
( q# Y" e5 t* X- I9 v - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();1 E6 S5 U# o# J) d+ e" h
. ~# I4 H1 I; a- t# U8 m/ K, s
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){4 s2 V" K R: U" c
- if(x1 == x2 && y1 == y2 && z1 == z2){
. K& o, p/ [( z. [ - return;* g6 F6 P# r* z; x4 J3 i+ y: C4 m
- }! d9 K: g1 [9 @9 c2 j6 N% X! r( G
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){) t. H" d& ?& v0 u" o
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");5 O6 v, \( D; q1 B* V8 ^* B( s
- }
3 M+ t6 ~; }2 n; t1 f$ J7 k+ ]! O4 } - pose.pushPose();6 Q4 U9 w# J; @* z8 [% l7 h8 o
- final int newLight = convertLight(6);( J+ m% K, D7 k" g. `9 E0 I0 c$ H
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
* M( F8 A5 S- p7 f* Q, _ - final float lineHeightSmall = (y2 - y1);& o# I- H0 s/ d; s
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);* E* `' M' g. M/ s, c
- pose.popPose();9 I1 E8 r' L9 E6 q9 S7 x, e
- }
$ R5 ~0 |3 X, ]$ ` - # i( [5 `+ G3 V1 Y8 T# i
- private RenderType getLayers(String texture, int light) {
% V" E! z D; a6 \1 ~) }7 N6 V - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));/ r T- T6 `! S& O/ o* q- p$ H
- }
1 P$ h# q( d' l1 S - - K9 ~; g+ Q2 z7 U- g* ?
- private RenderType getLightTexture(ResourceLocation texture) {
0 t1 M! @4 k" L7 D4 X! M - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);" Q) ?: Z9 u! o+ S2 D# y; p/ X$ v
- }9 _) `3 C1 ~7 g( @, ?- Z% T1 o
( b$ r" A+ {2 U- private RenderType getTexture(ResourceLocation texture) {
0 C* ^, m0 @- ^; a - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
: { m1 c' N$ |6 y5 Y - }
) Y/ d" {8 U- C
. ^ o" U" ?4 e, }, e9 M- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
: R+ ~- D D; u! N3 \ - if (cache.containsKey(identifier)) {* N# b: F, w' B) z9 x7 C P
- return cache.get(identifier);
' ]) L' J, T' G+ U - } else {1 m+ y9 s, R4 L* c1 S. v
- final RenderType renderLayer = supplier.get();
$ w* ?0 G2 ]5 y; H$ L - cache.put(identifier, renderLayer);! c' V$ L* u, M
- return renderLayer; O) L& Q) u2 U* C+ E! Q
- } v$ N! V# l; [; v
- }; t. y1 M" E9 T; }7 |- m" u
- }
复制代码 |
|