|
|
6 J' z: V/ J6 ~9 Y. `/ i5 B% f0 {行,这个怎么样
2 y% w3 O; I; w, H# q9 Z1 ?- ~- package com.xhg78999.mtrfac.render;
. K4 d( d0 S3 e9 [" y8 L - & h( x- o, [* s: P
- import com.mojang.blaze3d.vertex.PoseStack;
- P9 a/ I( C! r# M# S4 ?7 T! U - import com.mojang.blaze3d.vertex.VertexConsumer;
1 S) H2 e! f. X - import net.minecraft.client.renderer.RenderType;
: Z2 [" }) g( n - import net.minecraft.resources.ResourceLocation;
A+ n8 L5 L" o6 k1 A' }+ a3 _# U - ~' ^2 U/ ~; a4 J
- import java.util.*;
5 \& H, h9 G1 n: i - 9 w$ }& Z/ @3 |4 g! y
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(5 g2 ~; t, t* e6 P8 \2 Z
- # X; ~8 w+ F. ]* k, i8 D- q/ X+ c
- public class LineRender{
. {; b2 |3 ~" ?' G! x - private final PoseStack pose;* A/ S# ^# k- x1 V# w" R/ ^. R
- private final MultiBufferSource source;9 Y2 R! T1 j# B4 B+ {6 s1 M
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();8 c# h& i2 w& V( \; y
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
: i4 [* h1 l4 M0 x4 X5 u. f7 v
/ O( C) y) s: _0 M/ B0 R
2 F/ O! [$ O3 y$ Y4 {- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){$ @; b% Z0 o: L/ S& ~, E
- if(x1 == x2 && y1 == y2 && z1 == z2){
+ O! p& O4 F/ q5 C5 I7 [# { - return;
6 k' @, r, d' V' Y. L% R - }
; t+ C! ^+ I" _& T7 L - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){( Q* D6 K% P0 ]$ g2 z C
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");! l, k4 ~; b1 l: |4 U7 G A7 }0 R
- }( M# _, v2 Z5 f: i, J m' [& X
- pose.pushPose();: u1 C. |. X( \# s+ i
- final int newLight = convertLight(6);
. j3 u4 w/ b9 m7 G6 U - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));1 g$ m9 A5 }/ \" ^: {
- final float lineHeightSmall = (y2 - y1);
+ z# H8 Z( P$ v. I% a! H. u - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);3 P c2 @3 T" ^& W% G: x
- pose.popPose();
; X8 d1 Q4 i6 m - }* d9 t! r- H0 n3 e3 [. A/ t
- : @% h$ T) K+ X1 f5 p3 c
- private RenderType getLayers(String texture, int light) {
0 D# ?3 S6 W' G5 D - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));3 J1 Y* E# z7 K- X$ f6 N1 ]* s
- }
* V$ f4 A- w, B- f - 5 q1 @& _1 d) L7 c3 \7 C3 Q
- private RenderType getLightTexture(ResourceLocation texture) {
K$ D% u0 g7 X8 D3 Q% V - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);2 ~* ^9 \( U. H
- }/ @1 Y# D k$ q9 _ y
# Y" v1 Y5 }- j4 [# ]- private RenderType getTexture(ResourceLocation texture) {
7 ^5 w5 F/ V! Z - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
7 l2 \; P: c5 ? ]1 |8 T) u+ ? - }
+ n# [. r) }4 D- m - 5 f2 Z" y7 O4 T4 a( Y& @ J7 l
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {. ?, O/ ?* q0 m$ D
- if (cache.containsKey(identifier)) {
% ?; p8 T8 P3 Y f - return cache.get(identifier);; H6 b2 L J- j- H% D$ l
- } else {
& I0 n& v9 e! I# B - final RenderType renderLayer = supplier.get();% i8 w K$ Q( v+ l
- cache.put(identifier, renderLayer);3 b N) c8 Q- q$ q- ]: L- [
- return renderLayer;
- d K1 r1 j; z. U1 j: O7 R' I - }
* q8 Y' M0 t; r5 z - }) @. r; F/ p% z
- }
复制代码 |
|