|
|
; K7 `# Y9 F1 T9 r7 G
行,这个怎么样
! u& V0 I" d, x/ h7 \- package com.xhg78999.mtrfac.render;
/ Z6 O9 _0 c3 K0 Q
+ I, i- H/ w$ P- import com.mojang.blaze3d.vertex.PoseStack;. _/ L, X0 w* i3 _8 e2 c
- import com.mojang.blaze3d.vertex.VertexConsumer;# W! D' F% R3 B' m% k
- import net.minecraft.client.renderer.RenderType;1 u. ?- ^( v! o8 ^! c( n
- import net.minecraft.resources.ResourceLocation;
* K/ c8 `# B+ `5 Q8 F% ^. `% B2 U
$ ]. v( |, m' \8 c- import java.util.*;$ M( m, F5 G; ~3 ]. m- I( S
6 K4 e$ k2 U8 S4 u2 m. S+ k- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :() ^4 f9 M5 K5 L, W
9 `/ `" J9 g. s o. ]7 m- public class LineRender{0 B% o( k3 [* J
- private final PoseStack pose;0 N" T/ `5 h/ B
- private final MultiBufferSource source;! P3 p& K+ G' ?* G1 E: j
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
$ G7 O& D6 v7 e - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();4 W. F' J& I4 Z" c1 `7 H
( U5 d0 _/ ?) X' q' E6 ?+ k. \
J* e& A/ _6 u1 f9 I: w! E- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
5 }9 A, N8 }9 a6 M* ] - if(x1 == x2 && y1 == y2 && z1 == z2){
" ]& e6 |+ o: f5 R+ J% n- V. A( T7 J - return;+ E6 {. G7 D& \3 {/ I7 ?
- }7 C7 W3 @+ f8 K( t4 ?
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
2 O8 ?1 C* w0 A r4 w% ? - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");: w+ c: W2 |4 o7 r
- }
& D* D4 A& K9 @ - pose.pushPose();
. c0 z: _9 ?! c8 O1 U - final int newLight = convertLight(6);
) U2 Y' z+ ?2 }- O( d0 R! x3 R - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));5 x* K9 J, {, T
- final float lineHeightSmall = (y2 - y1);1 n1 C+ D# q( N6 W: L
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight); k8 x6 O v. q6 `# I9 B6 B/ F' A
- pose.popPose();7 G$ P9 p2 @: L
- }
4 l% m: E" F) v& Z) U, W - * S' G/ Q+ H0 M# @2 K
- private RenderType getLayers(String texture, int light) {- h& A: t; c1 m4 E3 f) Q+ n
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
- P. Q7 e# [8 I# o4 ? - }
: x* o3 X+ j4 w7 p8 F. B - . e6 m9 b4 y) G
- private RenderType getLightTexture(ResourceLocation texture) {
, _3 w4 @, d( P4 j- _; Z" s - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);5 `1 T& P5 ~4 c
- } _" E+ h; @; x6 s8 W! z; W
- 0 F" I6 ^8 \ M; w9 {0 {
- private RenderType getTexture(ResourceLocation texture) {
9 o: u3 D- `+ A9 u5 z - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
6 a& M$ T% s# J5 p - }( q+ {9 A o3 H& N+ M
- 3 h# n( Q3 Q0 |8 w% ~: A1 h# l
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {5 l( \# ~9 c& P) n
- if (cache.containsKey(identifier)) {
5 k' j0 V0 S4 o5 ]0 j( L$ a - return cache.get(identifier);8 r: @$ S. `- w" ~5 S) I; ?
- } else {
, b5 s8 \7 E. ~6 c - final RenderType renderLayer = supplier.get();
+ ], j& E O8 |" W - cache.put(identifier, renderLayer);% K5 J9 B1 m' P1 Q6 M4 a7 N; v1 |: v2 h
- return renderLayer;5 s3 ?2 `! B2 }; ?
- }
, ?6 |+ h9 ^* ` - }7 G h2 {/ O: Z$ @( f4 B$ _# s$ m
- }
复制代码 |
|