|
|
/ ^+ \1 h/ f2 o1 l* G6 M! h0 U
行,这个怎么样" b. a+ |8 U! ~5 x
- package com.xhg78999.mtrfac.render;; i) f& E1 c3 Z
8 c& [- D7 `. ]& W6 ^" `" C. m- import com.mojang.blaze3d.vertex.PoseStack;
. W; M# ]% |! j - import com.mojang.blaze3d.vertex.VertexConsumer;
. ]; v) `0 j9 A( Q9 i+ { - import net.minecraft.client.renderer.RenderType;, G" q9 e4 [! w+ Q& b" w
- import net.minecraft.resources.ResourceLocation;
3 h/ l5 o! P. O2 A( v; A - 8 B+ u6 h' h# _" ~0 V4 v# w9 k" P
- import java.util.*;1 W1 @6 J7 T3 f+ X9 k, O
- ) f! Y0 b0 b1 o0 V6 X
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(+ j4 w$ y( h9 C. s" W2 Y
- $ h, ]+ @. B4 I
- public class LineRender{
6 o2 F3 L) |! l$ S- l8 \/ m - private final PoseStack pose;
, d' J3 g. Z+ u3 b: v5 W; n+ P - private final MultiBufferSource source;$ P1 P |# ^9 F6 K2 q. s
- private static final Map<String, RenderType> CACHE_A = new HashMap<>(); c0 u5 N2 p) t9 l1 {+ f
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();/ p3 e& |$ r4 G' \! O* M
- s; D( B/ {+ z& M& S
2 i4 r% e/ M! s# N$ H# w- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){; D' k: w( S3 }9 \( r
- if(x1 == x2 && y1 == y2 && z1 == z2){% g6 |$ Y' k$ K {; n
- return;
% ~- o; C/ L: l4 P- w - }% w) Q3 h x- {0 @3 B
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
* e' {; _" a! x3 h - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");8 z% y6 B8 u* d6 u" z( i
- }
2 ]2 A8 P1 i. `% ~& s2 P - pose.pushPose();' e% Z8 B2 T5 G+ J
- final int newLight = convertLight(6);* n) E* k' v/ t! `/ u6 |! j
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));+ z* O1 `3 [, P( J
- final float lineHeightSmall = (y2 - y1);
/ i, j" `1 ?: U/ o0 N - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);& {# O& d1 j* O4 ^( f e# L
- pose.popPose();
* O4 _ o) m$ W% m3 \: t - } d; [! L- _4 D5 c
- 1 y1 h1 r. ]. Y/ t- t8 `6 D
- private RenderType getLayers(String texture, int light) {
" `# }& {5 {3 B" d$ [% v8 O# I - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
& r# d& F6 K o! Z0 p - }
2 p. L, }& ^7 P2 L8 S: P! @( R
, w6 z$ q6 t1 j! _1 L- private RenderType getLightTexture(ResourceLocation texture) {5 z4 ` [7 D$ p, R- b& _8 o
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
0 C! {: G) H1 V6 v* Q) p4 U - }, V; C V6 i) P- y' b& K# U
& L0 n2 D& [) \/ a( Z4 l- private RenderType getTexture(ResourceLocation texture) {, K. D k6 O* g0 O- Q% l8 K
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
& y2 j. I" D3 \/ \ - }' `+ s+ K+ b7 ^% A
* a5 L* j9 y0 E8 V- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
- ? }1 l( _5 y- y3 H7 h - if (cache.containsKey(identifier)) {9 ]* e5 i4 }( e! ~7 I# Y
- return cache.get(identifier);' N* u4 o6 z3 Q" x; N* F
- } else {- v ~! c" W8 k; H: d
- final RenderType renderLayer = supplier.get();* J( N! B( I5 |4 `0 V- {1 @
- cache.put(identifier, renderLayer);
. h) t2 s$ l3 R9 |* v - return renderLayer;
% L/ d' x8 c8 L. G7 \0 Y9 P - }! p& }3 o0 u# o/ Y# A4 G
- }
$ u1 a% [( ^. B2 y" L" W" L) e - }
复制代码 |
|