|
|
3 v* b% I4 C8 p, X% ?; o$ e, X; t
行,这个怎么样/ |8 M/ A0 C, ]
- package com.xhg78999.mtrfac.render;/ K. H3 \* m0 [9 i
1 v7 i4 T) D" t: v& ]; |% i1 V' p+ q8 k- import com.mojang.blaze3d.vertex.PoseStack;
7 [0 z+ R' L! t1 d: B" K - import com.mojang.blaze3d.vertex.VertexConsumer;
7 x4 T& I' O h9 [! o b1 G: \ - import net.minecraft.client.renderer.RenderType;* T4 }6 X+ o( B$ S0 \5 _" a
- import net.minecraft.resources.ResourceLocation;8 j4 }5 M. M5 F0 Q
- ' l" b# F/ P5 A) [4 t) d& e
- import java.util.*;* I- L' L9 U1 N" a7 m
- : n2 A2 E9 ? ~8 M* h) {
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
$ S+ G* P6 ]2 u; [( W - & \! \3 i% h4 C2 N
- public class LineRender{
; I& f- s, k# Z - private final PoseStack pose;
" |& a# I s9 a+ O - private final MultiBufferSource source;. @7 K6 y& W( a/ o( u! U
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();5 U6 y* Y1 y M9 R
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
0 l: l O# K& h# R: q( k
( M7 k- O$ R6 y- 0 L1 ~, z8 ?7 `: a, @
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){ R4 v: u4 A: C$ m# E
- if(x1 == x2 && y1 == y2 && z1 == z2){* j3 l# P, C8 A: _
- return;
# E: r; U6 P4 u- b7 z4 g1 _% \3 i - }8 ^/ d! o: p: x# F/ \
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){+ ~' G) ]$ t" T) B+ l/ p
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");) C/ j/ O, o. b/ Z/ }/ A
- }1 A% `0 ?$ J- R; O3 M
- pose.pushPose();! v- t% V( v5 M3 @ `
- final int newLight = convertLight(6);
. U$ W: n+ X( x0 v& c, @ - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));! u* f# X$ i, l& E
- final float lineHeightSmall = (y2 - y1);' g- J% _5 w, x5 s, D
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);# X% G; w' C' c- _
- pose.popPose();
. J" ] j& p! b h - }1 l' ]# _+ V4 }
- ' |$ V1 N; I7 b* Z4 {
- private RenderType getLayers(String texture, int light) {# V5 C+ w! a' ]7 O2 o
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
6 A3 U7 h6 p+ @3 M$ v - }
8 {4 \0 _! J j3 w: w: l - # w( d& d) ^( k# d/ U
- private RenderType getLightTexture(ResourceLocation texture) {9 _2 B) d' Q7 o( w' B, Q
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
5 X; y# g$ K* q6 v8 [( F - }
2 f8 G- o$ p2 v
- X. J _3 ~; r- private RenderType getTexture(ResourceLocation texture) {
* R( a0 y# _3 [4 G - return this.cache(texture, () -> entityCutout(texture), CACHE_B);+ ]/ y* k" w1 E6 n8 _$ l
- }
7 a" m" b: j4 s) c; X; Q - % S+ u* n5 J) H5 G0 ^
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
! z& W3 p4 g) I9 n' V - if (cache.containsKey(identifier)) {* Y8 N9 ?% p* c/ Z( n& \2 c; T2 W
- return cache.get(identifier);
* x0 L! G6 g! O - } else {6 Z/ u6 w; s3 x4 K U
- final RenderType renderLayer = supplier.get();. i7 p& }5 ^& R& U
- cache.put(identifier, renderLayer);
9 N& g( l( r- W' V - return renderLayer;
1 z" L7 ^ O l) ]6 E$ L - }+ A$ I3 x& {* K( U& J1 @0 }; ]. p
- }( z" u6 V2 J2 Q: c
- }
复制代码 |
|