|
|
* q4 H) h M X行,这个怎么样
8 ]; v: L' p. B- package com.xhg78999.mtrfac.render;& y: C- ]" q8 i
- ' Y: G7 i2 o# x
- import com.mojang.blaze3d.vertex.PoseStack;+ K: _ ~* x6 V) u7 R5 w* x- v
- import com.mojang.blaze3d.vertex.VertexConsumer;0 T: `: s! i+ v
- import net.minecraft.client.renderer.RenderType;
- B* n) M$ X: D5 \/ |' O) {/ ~ - import net.minecraft.resources.ResourceLocation;
$ P! g1 z u: ]! v( U. w5 F
6 T1 l B9 r2 M; J- m- import java.util.*;1 c @' q9 ^$ _0 o: ~2 g
- O- b- o0 ?' p4 Z) R L8 v, T- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
& c6 w8 y0 Q, O/ s
0 H0 K% ^. g) Y q- public class LineRender{* R! X& H. U5 n5 o* @; P, |; y
- private final PoseStack pose;! v+ y' ?5 t5 l8 k& X2 X
- private final MultiBufferSource source; u' C9 a/ P1 k5 |& I- d
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
* Y; k! `( c; ~% G - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
s1 X/ Q% Z6 p& `( J$ U3 @) J
; V" v& ^0 @" o5 x: M7 [- V- ) k$ U9 ]) J }. p8 Q
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){. V, k7 g7 b4 Q7 }
- if(x1 == x2 && y1 == y2 && z1 == z2){; `/ X1 c1 l# l5 v; S1 j
- return;8 e: x) }. M+ S$ j; J+ k
- }
% j1 r) w! Y; {% h2 F! i) o# b - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){9 G: L, O& Z y+ F' ?" t! @
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");1 D, Q" v" F6 h
- }: L& a1 O4 m+ c: ^7 X* W7 W
- pose.pushPose();
9 X9 P* a" M% l' |9 X- j) I" ` - final int newLight = convertLight(6);
5 l+ P/ W$ a) t - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
( N" E( g y% }1 X% O1 |" C8 C, @ - final float lineHeightSmall = (y2 - y1);
7 O) p4 y! a/ q2 U0 P5 G - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);3 ^7 W3 f2 c/ k, M) s2 ?- a8 X$ @
- pose.popPose();5 k1 u# B M0 }) O
- }
! U5 [) r, J2 J2 s6 N
9 H9 m, K0 D4 g/ z5 W1 U4 K- private RenderType getLayers(String texture, int light) {
; o1 S1 ]. Q; O) x0 o - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
( D4 |, Q( p* ^( s4 \, Z- o } - }" t/ z" X# J; J9 H0 Z
) q- J. M: k1 t- C* b8 o- private RenderType getLightTexture(ResourceLocation texture) {; t% b1 l! {4 \ H9 _, {/ o; d# W3 d
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
8 @# x, H& \ J# x3 s! B - }+ U7 D: J2 A; {* P( Z
- $ T3 h3 y; z2 D3 [
- private RenderType getTexture(ResourceLocation texture) {
8 b1 o! w& G {/ S% [ - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
& B5 g$ |& b6 C& @ - }
: G1 D9 r) r$ D! \3 S% a. F4 @
7 p" _) w, \; n8 T& @5 R- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {; I/ T/ r3 i" N8 U1 c
- if (cache.containsKey(identifier)) {3 w$ \- C) |- [! T( L! c) ~
- return cache.get(identifier);
) O: h C! ~- [. O: C, L/ u5 ] - } else {: W8 j6 I6 ?! i4 A& i
- final RenderType renderLayer = supplier.get();2 ~( U5 q) `- q- O9 j p* i
- cache.put(identifier, renderLayer);, k, V S2 X7 @1 A' r3 x
- return renderLayer;
$ J- T% d6 c2 B6 {+ Y% l - }: T& W1 j% ?6 v" K
- }
* T. h, V1 {, E3 `2 ~( h0 y - }
复制代码 |
|