|
|
% e* m# i" ~% @
行,这个怎么样
! _1 T) b+ T( i- package com.xhg78999.mtrfac.render;. C, J/ B4 Y, R% u+ c
! \5 P# K% e& y8 ?- import com.mojang.blaze3d.vertex.PoseStack;2 L$ Y+ U$ J a; }
- import com.mojang.blaze3d.vertex.VertexConsumer;8 t4 v% x7 ]2 D2 T$ W' r P
- import net.minecraft.client.renderer.RenderType;, _8 U7 G7 X5 }! D
- import net.minecraft.resources.ResourceLocation;6 @2 n1 N; M: k2 b6 p/ W, e
% K- f1 a& h' k5 I# b- import java.util.*;
- S) p& ~3 K) y/ J: h' K1 |
. I3 m: A( e, W Z0 ]& A- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
% s# e6 o6 h S2 |$ S4 j# n
' l, x7 _$ S: B- {: r; ~. S- public class LineRender{- r$ |, `9 ]; m& I' z$ R; V
- private final PoseStack pose;8 ^2 {' o! L* k M& o; ^7 F
- private final MultiBufferSource source;
% w" k) W: a' P( x# c/ w - private static final Map<String, RenderType> CACHE_A = new HashMap<>();* Q0 U* x7 |7 v P
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
' Z* T Y6 t! S. ~ i$ N' u
, K1 Y( K8 m6 G* w/ a" S
, F& A' h+ s5 B0 \" j4 t; k3 t, h- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){* ~ K& b1 e* s- c
- if(x1 == x2 && y1 == y2 && z1 == z2){
6 h0 G$ r; }3 \ - return;
# L; w- f/ O! e* i - }9 ^5 H0 A+ |+ S" r6 I1 f2 B( A
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){" P" E& j# x/ j4 }$ D6 R# c
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
7 F* _5 c f+ g, ~! |. n - }
e; [9 l4 ]8 t7 R2 Y, W - pose.pushPose();3 Y2 t1 _2 _3 V( Z9 {/ U% {
- final int newLight = convertLight(6);
/ T: G5 `3 t2 m - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));: G7 r- j5 u" O* I1 v* W
- final float lineHeightSmall = (y2 - y1);" H7 m$ M, {% B( h7 j. C3 \ f
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
. |: t) g4 N6 \5 O! b) D. J - pose.popPose();
: t+ ]& M6 o4 s8 k - }
( L" O4 P- \, ]8 O
: b5 B+ L% B/ e9 j0 Q5 P( S- private RenderType getLayers(String texture, int light) {' n& H9 }7 ?! N3 ?/ P/ N
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
% f. T( P3 q; z - }
: }- L1 v/ c; W/ u1 } - 7 m/ P9 ]( R: {% t
- private RenderType getLightTexture(ResourceLocation texture) {6 O1 I* f# W5 B9 ?
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
0 o0 t& M* d3 [, K1 |0 Y6 B - }) C2 d" Y0 ^" S8 p* ^' {* {% n4 p
$ x. I( x3 E* i- private RenderType getTexture(ResourceLocation texture) {4 \: s, t' G0 ]. f4 Y4 u
- return this.cache(texture, () -> entityCutout(texture), CACHE_B); e: q0 B$ _) A3 Q' O5 k# N
- }
1 e: Z% `. |: l; K - 2 D3 `4 c2 ?- e/ y* }
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {% W3 D: L1 D, u: \! b
- if (cache.containsKey(identifier)) {. \2 m% C. K) K, n* @
- return cache.get(identifier);
. v7 I# \& B9 e2 m& ]: E4 o# X - } else {
* W; W }" M5 `% R( i) n3 c - final RenderType renderLayer = supplier.get();* a8 j \/ t, `! I5 u9 \! x
- cache.put(identifier, renderLayer);: o# X; f. ^0 H2 {0 V/ s
- return renderLayer;
$ D) D/ o4 D& t! h) i - }
- y' |$ h/ T. K: ~, U/ U7 q7 j - }) J9 s( g, W, ~* Y" {. I& X
- }
复制代码 |
|