|
|
9 J1 a6 w4 F. A: m+ l' ^3 S
行,这个怎么样8 c# j- J5 c7 G
- package com.xhg78999.mtrfac.render;" W* T2 M' [$ q9 l+ V0 s
/ o: L7 y: D! p$ h* O- import com.mojang.blaze3d.vertex.PoseStack;" ]2 S8 H$ T. f
- import com.mojang.blaze3d.vertex.VertexConsumer;
. j: c' D3 a# K' i k. R - import net.minecraft.client.renderer.RenderType;
7 h; |, {& ]: Y8 ~! {/ [ - import net.minecraft.resources.ResourceLocation;9 d5 o) y8 b: m; d3 P" y" l
- 3 _, K) ^! k. H$ K- V; Z
- import java.util.*;( ^+ H' y# D/ O- n d: g
& B% B% F9 `% ?) K- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
( ]3 a, @# K! Z - 1 W) y( E* B+ f
- public class LineRender{
* W" L' U" H9 ]5 [* w9 l* E+ } - private final PoseStack pose;
, ^4 F: v* R1 ? - private final MultiBufferSource source;$ Q R' _4 }) z" x, R6 l& F6 B
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();$ O1 G5 O* `7 v- |* W8 v( N/ w; n* ^
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();; J9 @3 g% H$ u* v: C- v' J0 `" `
- }. S) b( g$ [
1 S; ]% @- ]+ P- z. [, E- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){+ n* U- ]3 }6 z' H! U1 P p- h& A: L
- if(x1 == x2 && y1 == y2 && z1 == z2){
/ c- W9 R& [% S. r: z - return;
8 d' P" t7 r" F - }3 G$ a& o' k1 J! E! F0 |
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){- K% b$ |- A: k1 D
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");1 t" r# E6 {, v/ K$ {# R8 M1 v c$ p
- }# D( O5 g6 z& ]/ r4 r; s- S
- pose.pushPose();
6 _% C9 e9 d! ^" ^4 A - final int newLight = convertLight(6);4 A; ]5 K( v4 M3 o8 V z4 x- w
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));1 ]+ j" s0 C: d4 B& P3 N+ s
- final float lineHeightSmall = (y2 - y1);7 O [; G4 {" u* e" F1 U
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
/ e# N2 G3 J: k& b1 C% E. u" M9 A - pose.popPose();& D: p, V% L# x, z
- }" x1 K3 u1 i. p# P6 K$ ?9 \
3 \ {' B* [) E0 u( h( D- private RenderType getLayers(String texture, int light) {
0 g) M- O9 C$ m& C% F - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));: M6 U7 |3 ~: ]
- }
1 l* ~) n( s. Q1 L" p, l - 8 }1 ?9 F$ m' r% A$ v1 e
- private RenderType getLightTexture(ResourceLocation texture) {3 x! Q/ {4 V* m
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
' Y" L# [; Q# J- |1 d - }
$ K: |3 u9 s) s' C7 Q! o
. ~% ~" B7 M) p2 S( v7 k- private RenderType getTexture(ResourceLocation texture) {
4 ~6 ~& U: E. E" O - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
) p+ f/ g' x' {+ h' O - }7 R! m) y2 w3 P+ X+ l$ I4 T9 {) N
- " F! y) x( ^, ~: P9 W4 C" Y% @
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {8 q7 u, k: G0 s$ T0 N
- if (cache.containsKey(identifier)) {& `( M$ K* ^1 P! t1 _3 I( H( R
- return cache.get(identifier);, P8 d) D$ ^2 K
- } else {. s5 o! }: E: N( }- Y; T9 X
- final RenderType renderLayer = supplier.get();
9 \- p% H) `2 a) |( |) m - cache.put(identifier, renderLayer);/ ~' z0 k) B0 `& W' f8 V
- return renderLayer;' r! a/ T2 C4 ~; i
- }& U7 g4 E6 ]3 `! p+ s
- }4 J M( O. D- v! g8 ?4 C+ }1 q
- }
复制代码 |
|