|
|
6 k4 q) M/ i) S
行,这个怎么样/ y0 u" E/ x( e) L' b
- package com.xhg78999.mtrfac.render;
; Q( n; p/ O# S' e+ |. Q
5 r& ?9 c6 b( [' [- import com.mojang.blaze3d.vertex.PoseStack;
* B8 x$ ~7 R# U, ~4 ]7 w: y - import com.mojang.blaze3d.vertex.VertexConsumer;+ f+ B7 P8 M0 V
- import net.minecraft.client.renderer.RenderType;' x% W/ {/ l S% Y9 x+ c/ |
- import net.minecraft.resources.ResourceLocation;$ o( |4 x, M0 Z# N% J+ d
- % q3 u. ?- E, |0 R
- import java.util.*;$ e8 _# U1 k- m
: ] w! D: u# c% O8 t- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
6 @( F/ ?/ Z3 a! C' p s( t( s! h
+ V- v* g4 ?4 X* d/ _ l& E1 B; ~- public class LineRender{
5 g1 c& o# i& U4 Q - private final PoseStack pose;( w( z" k4 [6 n. @+ n* g1 k
- private final MultiBufferSource source;9 S: R. @# p1 Z1 @$ Y
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();$ J& \& `9 X/ @# ^- h- W* Q
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();3 L( a" P- h# h
0 d% F# s3 S ~/ o* F1 `2 d
8 W5 s2 B+ U3 `& Z# A- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
: M- \$ h1 M% p% K - if(x1 == x2 && y1 == y2 && z1 == z2){
4 w' A% }, U( k4 ]. i - return;8 {6 T J) T0 S0 S2 ?1 D
- }+ i" E# g4 m! @, B- I
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
T+ Q) ^, X+ w5 h8 S4 k m - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
6 k/ R2 F* S; p3 @! C - }& I* V$ n9 r2 Z, P$ v
- pose.pushPose();
- U* i5 w. c( Z: Q7 [1 l7 h3 N - final int newLight = convertLight(6);
8 W; Y( U7 _( E y0 k3 J: B2 b/ O - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
3 a$ b) i7 |# n7 M6 i4 g - final float lineHeightSmall = (y2 - y1);! I( V! X o9 o# Q( b3 H0 r: B
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);* ?/ Y* W2 D# }* J
- pose.popPose();
7 D4 t+ f5 I7 r; F - }
6 t7 _' G. z/ K B- }8 s, C# a' Q
3 B' c: t; ^6 ]( u3 @! S6 p5 o5 w- private RenderType getLayers(String texture, int light) {
3 v N+ v2 k0 A% s7 g7 d0 { - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
- v5 \) e& Z/ T - }
J" A/ |- T8 {! O7 a
' {) r. k8 r2 J8 g5 a- private RenderType getLightTexture(ResourceLocation texture) {# _( R# j4 s8 H4 G' t$ g% e
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);( ^, ]( r; B. V" \0 y5 K3 W
- }
& Z5 W! v) m0 f. F. u6 I" [, Z
* w) {) o) N2 U3 {7 H! n; u- private RenderType getTexture(ResourceLocation texture) {. }' `4 y7 k0 \- h) L
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
+ B6 d9 H' J4 b0 N/ g5 e2 u - } ~- i8 s Q. `
- # S, p6 O. V' v- f2 h( D/ u- I5 Q0 W
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
7 t9 z- @. s% `6 x/ l# ` - if (cache.containsKey(identifier)) {
9 H4 ^6 y( y4 R" ]$ R - return cache.get(identifier);6 p' q/ R4 w9 U6 W
- } else {
4 I* U6 A3 \# x - final RenderType renderLayer = supplier.get();. ?$ l: F/ I3 S$ Q5 _7 V
- cache.put(identifier, renderLayer);
/ M7 J* D, `4 v+ N1 |2 h: U - return renderLayer;
# a# O) d0 l0 Y - }
( a$ |& D3 h4 y4 ^ - }, c1 k, c% w# Z& V6 a; W. G
- }
复制代码 |
|