|
|
0 z. t" Y U+ K6 S' W8 b
行,这个怎么样
8 g ]% K) {* w3 P3 d j; T- package com.xhg78999.mtrfac.render; h; E/ q+ M3 x; R9 U
- / ]; H4 l9 ?1 Q( l0 I2 h
- import com.mojang.blaze3d.vertex.PoseStack;7 W( u( x; n7 V" }. i
- import com.mojang.blaze3d.vertex.VertexConsumer;. b1 X* y- D a2 R
- import net.minecraft.client.renderer.RenderType;, Q5 r2 T. h/ J9 E! G. ]
- import net.minecraft.resources.ResourceLocation;( a2 }7 @* o3 f* I; _2 v
- : H/ u' H* O! b3 T
- import java.util.*;9 d+ y! V! q; O# z
- 3 `4 M& C7 G! ^/ a: m# P5 w
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(0 I, |9 f/ f2 ^1 v/ u
+ f. N0 Q9 c, P8 ~ {9 b- public class LineRender{
! {* x" U$ y/ }3 z6 G5 Z9 w8 o - private final PoseStack pose;
9 x" X7 v& M# d, m7 W0 K! ^ - private final MultiBufferSource source;; b! x7 `; z4 g7 h2 D I
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();8 K0 }1 H2 z9 i4 W- c0 G3 i
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();! O% b4 \9 z3 m1 W
: l1 c6 A" W A1 ^7 W! @- - \1 L `% ]1 z
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){. Z( V8 U- w, a {
- if(x1 == x2 && y1 == y2 && z1 == z2){
- \. P8 B/ Z" g0 X" } - return;
3 A* m+ e0 e$ Y2 m: m - }( p; v( j2 i- ^3 X# C0 I
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
2 K" B+ X- K3 O- l - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
- g2 ]/ C4 i- F9 w9 l8 O6 L" z! g; @ - }) d; V+ p$ R# K/ i
- pose.pushPose();1 u/ m" ]1 O2 n
- final int newLight = convertLight(6);! [0 ~0 B, X- [& l6 p7 [3 @4 W
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
; H' e6 Q& O- \ Q' _ - final float lineHeightSmall = (y2 - y1);3 f+ T3 Q6 D4 l" y
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);) i1 S+ b. R$ C
- pose.popPose();
0 ~! j) t% d' T+ P* a9 k# N - }
7 s) J( X0 q, I& c7 x9 q$ g3 w
7 j# h$ D1 K9 \5 l4 E- private RenderType getLayers(String texture, int light) {' y$ }8 D2 |) A& F; o
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));/ W8 B+ K- @% O1 n% h& r" y
- }
7 v( M4 j2 |3 p - * P/ X+ ?8 a1 S/ ?
- private RenderType getLightTexture(ResourceLocation texture) {: C. ?- U! K1 O
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
, i; u7 M7 d. b$ D+ X. g2 R) J - }& O9 E6 w; a2 N2 m4 a& T# j
" k( D! d" {$ Y" h/ @- private RenderType getTexture(ResourceLocation texture) {
4 v$ C! r: G1 v" Z4 v0 j - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
0 o$ q: ^( p( s% ?, Z5 X - }" A0 T) u+ {9 o
- * M8 {' p% g1 i. i9 M
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
- | k6 U* [# ]( u# V. r - if (cache.containsKey(identifier)) {$ u& X7 d6 c" ^5 s, P
- return cache.get(identifier);7 p- A+ f5 z* r5 [* v8 R# G
- } else {& a# W4 s( R0 N7 ]8 M9 p
- final RenderType renderLayer = supplier.get();
, r; e+ J* d. F" Z. D - cache.put(identifier, renderLayer);
% T0 K! w$ n* z9 g/ h9 O* v - return renderLayer;2 b5 j4 |" R& l2 G# a* e
- }8 {- z1 y D- y: {7 p4 o0 l
- }3 U7 _4 k- @( u' m1 V
- }
复制代码 |
|