|
|
/ l0 f l* m4 p7 F- R7 @' n, X
行,这个怎么样
. f# J$ `9 U6 S( N. G' s- package com.xhg78999.mtrfac.render;
% p q, w$ o3 f9 ] G; m
3 A( r" Q9 k+ ~- import com.mojang.blaze3d.vertex.PoseStack;6 T! R: U: j) r7 h7 N+ q5 V
- import com.mojang.blaze3d.vertex.VertexConsumer;6 g4 O. B1 w$ T
- import net.minecraft.client.renderer.RenderType;* l& G) n( @7 g. \
- import net.minecraft.resources.ResourceLocation;
1 i& j) j4 |2 T; |/ b9 W$ }: `, b9 p - ; }6 z- a: G8 b% c% b+ ?
- import java.util.*;: D6 W; r' x5 n3 {% s# w. g" `' g5 |
2 C2 Q" \7 T4 R, v; T# f7 J- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
( p% y/ l1 _4 y7 R9 n - 5 u4 c0 w) {$ }
- public class LineRender{
x9 g- o4 d+ h" {9 J7 ? - private final PoseStack pose;3 |4 T' N; U/ ~
- private final MultiBufferSource source;2 m% B. m0 u, y* c; C
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
" `3 Y4 K- V3 `; D - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();( I; a1 \; k0 o$ o1 s
$ K- T* b4 q4 H2 ?8 \) P$ Z9 h- 2 o+ X2 G+ ]4 I( J; z6 Y
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){# L( u5 W' W! r
- if(x1 == x2 && y1 == y2 && z1 == z2){0 J" J1 O5 \( s, a: K1 e
- return;
. N$ M+ S, V: b9 k& Q K% n1 V* c - }7 B0 w. s% r; d- Q* E
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){0 k" r. c9 e! }# C
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
$ S$ W5 F, `3 l7 s- A8 S - }
6 A! \) w- @0 a( C+ Q) Z- p - pose.pushPose();' Q! T$ `' q* N7 R- r
- final int newLight = convertLight(6);
1 I, R" w. q- ?* D" t- t9 H - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));* |4 s) b$ ~ ]
- final float lineHeightSmall = (y2 - y1);- S4 s9 |$ [4 A, L* H6 R; m; i
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);5 @ f4 X: v$ F* C6 Y$ y
- pose.popPose();
) c' b) S4 G" k - }
: O& n% l3 s# o: [5 Q1 Y - * w! r% b) N1 T( S( i5 n2 l/ f
- private RenderType getLayers(String texture, int light) {* t* T0 n1 M( d
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));' |, ], W/ c* y3 Z/ E
- }$ o8 p. D8 L% P2 N) B& r
- & L% _8 A4 c/ `6 N1 X
- private RenderType getLightTexture(ResourceLocation texture) {
" _6 k& m! _% g2 E - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
7 ]# f& {; q8 d4 O" c - }
) \3 U% k$ Q4 S6 c d. E9 u
) Y1 L- X7 U# `8 s* v, _- private RenderType getTexture(ResourceLocation texture) {& g+ i1 j) k' D9 j( |) i* R+ N
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
3 o' _$ }6 L; b4 r" w0 B# e - }
: W) c5 f3 L: l& W- `1 p - 7 ]3 L! b* [4 L, X# Z
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {9 }4 F' o; m( u0 q4 }& r' h1 _
- if (cache.containsKey(identifier)) {
, ?9 j7 W( b4 i# { - return cache.get(identifier);# k" d. l2 Y# C p0 G% K
- } else {
* e; {; N7 v" C/ `8 n$ D6 O1 o2 I" Y4 \ - final RenderType renderLayer = supplier.get();
# C" Y; }1 L/ }" H0 q- S - cache.put(identifier, renderLayer);6 C+ J. D" H5 Z6 {% [% K
- return renderLayer;
; Z/ v- D8 e7 _ - }7 g' Y @, n* y
- }
0 P1 x" |1 d. e8 o6 Z* o - }
复制代码 |
|