|
|
" d" n; j& X7 i# W9 }3 d9 {
行,这个怎么样
f' y1 T! m `: V& E" ^' I- package com.xhg78999.mtrfac.render;
5 o0 o8 x3 p. J t s - * K( u6 t* w) [1 A7 e
- import com.mojang.blaze3d.vertex.PoseStack;
9 A1 ?. ?% s0 o i - import com.mojang.blaze3d.vertex.VertexConsumer;
, K1 U" t: ?7 i/ _ - import net.minecraft.client.renderer.RenderType;
; H0 p0 _$ Z+ ?+ ?6 p! I - import net.minecraft.resources.ResourceLocation;
2 T( J8 d% `" V
# |( Y/ ~; b7 \& R; ?' o4 o- import java.util.*;
& E5 G! U8 U! `* I
* V' ?7 p6 c9 N( o. i3 W- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
. V: u! Z( n E0 L, T - & K+ v6 T, j- t8 J: `, h
- public class LineRender{* K; g M! O# h
- private final PoseStack pose;
; @( k$ s$ Q: `1 ]% X: @+ Q2 E. e - private final MultiBufferSource source;- S8 ~$ P) |$ i" c2 @
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();9 y* [- T1 I# E9 G
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();+ Q8 ?% F; e9 T& k8 `
+ Z/ K1 U# }5 z ]
' @+ O$ l: _+ n1 I% O9 W- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){! u, L% A! n5 E/ U, }5 w: _% f
- if(x1 == x2 && y1 == y2 && z1 == z2){
7 v4 ]; k3 U; H$ }* h& i8 h - return;
6 G% y: {) `3 G/ N4 _ - }
- i. S, K! J. [) p, E& R! X- V - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){5 n! }# S: s' v0 c9 M6 I- x6 T X
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
8 ^7 f$ F8 s) n. C8 n! H - }6 j1 Z, K" Q( P* ~( o
- pose.pushPose();2 O4 m0 S. S% z; ~3 E( n0 J
- final int newLight = convertLight(6);7 h5 p/ K! ?6 F3 U7 w
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
" \3 B6 F! y$ a$ ~$ k7 g - final float lineHeightSmall = (y2 - y1);
0 x: D, |' [3 _' C$ Y- S - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
# `. A1 f0 T( I/ ~ - pose.popPose();6 a6 ~% `7 w1 \1 Z
- }) S. M9 E& u, w
- % {" A: s- Z Q- @% D! C0 ~ X1 K
- private RenderType getLayers(String texture, int light) { {" g" R( {# e: E; a
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));+ @1 w/ M' H0 i; ^1 S) Q
- }
# i( q1 e+ `- _
4 r# o) r7 r% s8 S" g& s0 q- private RenderType getLightTexture(ResourceLocation texture) {
1 `* n" h* a+ H/ k" Z4 I# x5 n5 H - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);* d+ F( x A8 r* Z
- }
/ U' q; J' `: v2 V" [! G - , i. [) q0 T8 d1 T7 K+ C5 L
- private RenderType getTexture(ResourceLocation texture) {
$ i* G' ?- x* K8 r T. M - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
6 m+ Z+ P( L& [ - }
. L7 `. u5 i. q$ [* } c; A
* J7 b/ J# x6 i5 ~7 r; A' V- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {" K1 j; w6 t& t
- if (cache.containsKey(identifier)) {
. w) Z* m* a6 v1 J. w5 s+ ~6 H8 w - return cache.get(identifier);# `, J7 O% T8 t# D' S4 B1 v
- } else {
* A5 B% D2 q" R- g* O! f - final RenderType renderLayer = supplier.get();
" ]$ Z# D( I: Y6 @ - cache.put(identifier, renderLayer);
8 \, t+ S( f- t& O# O/ J3 ` - return renderLayer;
7 i) I9 I( O8 _/ {9 }2 f- m - }
6 m7 Y/ n: [2 Z) M0 s% F7 x - }
* @2 C' O$ |- E0 i$ ] - }
复制代码 |
|