|
|
" T& B1 ^ W' D# I# j
行,这个怎么样" T6 n9 [5 l' p0 A9 @
- package com.xhg78999.mtrfac.render;
0 X6 M4 l# C2 p1 [/ v& A - 9 k+ Q9 X! u9 N
- import com.mojang.blaze3d.vertex.PoseStack;8 c. @, a7 d2 Y3 R9 `3 a6 F. d
- import com.mojang.blaze3d.vertex.VertexConsumer;+ {$ s7 }5 P) h ^# {/ _
- import net.minecraft.client.renderer.RenderType;
9 i8 c5 B' d0 A/ c6 } - import net.minecraft.resources.ResourceLocation;
4 u# F7 p# G V - , E1 M$ A# z" M1 P) v. Q
- import java.util.*;
# Q- w( c# R. y! a - 2 e+ W; \- k2 K7 w, z3 g
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(! t$ j. F O& l# p- ]
7 O) i3 d V' h9 G1 N5 ]; |- public class LineRender{8 @. K/ U) t+ Z0 q2 ?9 g
- private final PoseStack pose;
& t x/ U4 n+ U. w- i/ U - private final MultiBufferSource source;
* @& X. g7 v6 _- X( b - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
- |4 {. [5 w/ {( L7 T" V/ f/ O - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
) l: [4 b7 j% j8 I
$ I5 B3 h' {7 m3 o$ H% R# c/ B1 H- 5 w# Y: \$ l$ S0 ~) J8 R, B0 k$ U& ~
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){5 E! X- Y5 }% k w- f' h7 ]
- if(x1 == x2 && y1 == y2 && z1 == z2){
, n- P8 z" K6 ?. a' R - return;
, {2 t9 V& n& r: \- h0 ? - }7 m+ x( o: o6 W. w! T' @2 c
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
: h* K5 o1 W4 A; S" N1 L% M - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");+ l, X" U, S4 Z j% e% n! u4 \
- }
: \2 M \3 @- o - pose.pushPose();$ M% ^% [1 l6 k2 h$ Y, r
- final int newLight = convertLight(6);6 G# }# y4 P, X5 B& f6 r. f
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));( F. s. v) j5 W; j% y
- final float lineHeightSmall = (y2 - y1);4 S' M- ~# x& k" f
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);, c9 r9 B5 C) t( e. K
- pose.popPose(); V( g$ n$ r$ y& l
- }
' Z/ z5 I6 _; t1 @0 K. k0 ^0 U; X - 5 A# y3 E5 V! x; Y! }$ R: @
- private RenderType getLayers(String texture, int light) {. }% ?; U& X1 o+ w
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));: C0 c7 Q/ N4 R! ?% ]2 l+ K
- }9 I+ w3 W8 _- B j4 N9 |- g
% H) P% O3 y& z& r- private RenderType getLightTexture(ResourceLocation texture) {
( B# P0 E8 a ?6 t( d' d3 h' ?8 X - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);- \- Y& j% F" S3 ], i
- }; t& L9 Y8 q5 l6 m+ G
- [. s$ Y# H" [
- private RenderType getTexture(ResourceLocation texture) {( B4 W( T/ u' {0 `( U+ S' e
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);/ B& [3 }: K4 L( n; Z8 {6 ]
- }3 f0 W! U2 D: b F$ s6 b& z
3 M S/ \# \( `+ V5 Q: I$ N- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
# J i3 E: @ Z( c - if (cache.containsKey(identifier)) {
. _: e% M6 Y8 k$ ] - return cache.get(identifier);
: p5 a3 s" u f( p& F - } else {
7 C j! e& K& T- Y - final RenderType renderLayer = supplier.get();
3 ~/ L1 E3 b& D& u/ w8 m9 v f6 ~ - cache.put(identifier, renderLayer);- ?) J6 X# k/ |: n
- return renderLayer;
5 _& g- d& w# c$ o - }7 X1 G/ N/ |/ W* z0 ?8 ^+ A
- }
, Z$ Y, o) [. [1 l5 b - }
复制代码 |
|