|
|
; o+ |9 O8 g) g* b: F. \7 [行,这个怎么样! T ]% F2 i/ I; W
- package com.xhg78999.mtrfac.render;7 z2 p! r. n9 a' m% T. r) i4 [
& ~' t& V: L' r" Z0 F5 O- import com.mojang.blaze3d.vertex.PoseStack;
8 }9 l0 a3 R1 x c; |8 ?5 P - import com.mojang.blaze3d.vertex.VertexConsumer;
% R3 X2 _& r3 }4 t0 L2 }+ Y - import net.minecraft.client.renderer.RenderType;$ V: \' s( Q3 N7 ?/ M
- import net.minecraft.resources.ResourceLocation;7 g' k7 U1 n, b8 o8 i9 \4 ?
- # t" ]3 R9 h, `* z" [. j) V3 y
- import java.util.*;
8 }0 U7 T; @- \ - * e3 U- G4 V: _" X8 r
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(- C2 D, |) q1 \. B' i x. |3 {
- ( z% |+ H% S6 T& S& X0 a; h* R
- public class LineRender{5 w8 s1 j+ `' v0 Z5 s. G
- private final PoseStack pose;* O2 L# s; ^2 I5 Y2 q/ q5 P
- private final MultiBufferSource source;& B0 j! K* Z" o
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
- B! ^$ Y9 ^# f% }9 B/ z f - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
$ ~/ o+ s; ^! D) G - # P- T- J! q8 S1 t, i( S" x
* j! l/ @' B7 B# i6 p+ A" H. N) J$ Z- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){0 d5 ?' v' C/ n) [9 x: L; V- L
- if(x1 == x2 && y1 == y2 && z1 == z2){
7 ~6 y- G& \" e - return;
- Z: z8 n( Z; X, q - }
6 ^7 c% e1 [3 S; s - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){9 f, W) P8 k9 n' Q) u6 i
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");- Z& p7 b1 W6 @# V- c$ @
- }, _/ E# l3 N0 @
- pose.pushPose();
/ H! G7 \- g2 q7 @( Q1 p - final int newLight = convertLight(6);9 h3 c' R& @5 K" E) {
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false)); t% U' d: W' p, x* v
- final float lineHeightSmall = (y2 - y1);
U* P" G( l+ h4 p- }1 \; L; g - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
0 x0 M! g/ o. [. a# T0 i - pose.popPose();2 f" A/ O. f% h: c' g* t
- }
( W4 g, c8 p5 U3 C/ p- D
7 ^% q9 ?4 I% e) ~+ d; g- private RenderType getLayers(String texture, int light) {1 r9 N4 T# x9 G; S \; ~
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));( }# M; K+ Y9 k. n$ |
- }
6 w& f8 f& Q3 O# E/ u - ) E" }% r4 |2 E
- private RenderType getLightTexture(ResourceLocation texture) {) J- S$ f* D1 A3 m6 n' J2 f
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
! \" n- |6 \- c# w/ P - }% k& M2 r2 O( F" u, @1 r
- 2 D3 O1 ]- N/ K' o" o
- private RenderType getTexture(ResourceLocation texture) {. T; Y U, D! u) O) A# P$ B
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
3 i3 w, V: E7 e' ? - }
4 f( f: V* i5 P& J - + M) J H5 z3 j/ Z: G9 M
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {" z- f1 O$ t& g7 g
- if (cache.containsKey(identifier)) {, b/ S2 [+ f L: S" X- h) z1 |
- return cache.get(identifier);
: S9 B( c1 m& l! B% V2 V; K, p - } else {
$ ?6 U4 T. z8 w8 F! u8 z. ] - final RenderType renderLayer = supplier.get();
u: d) m2 N s" O - cache.put(identifier, renderLayer);
% A: m* _1 G/ o( a - return renderLayer;/ U( R" z) h' D
- }
7 n) j, M8 V# \( v - }
. H" q/ `2 v: }, C" w Y - }
复制代码 |
|