|
( v# w" `: i6 L r& V
行,这个怎么样
5 n% Q' I; C5 U- E1 A3 ~ T2 P- package com.xhg78999.mtrfac.render;1 k7 M" F* w" @3 P" E
+ R+ i( K" c/ U- u- import com.mojang.blaze3d.vertex.PoseStack;- X$ _8 z( S8 t7 d
- import com.mojang.blaze3d.vertex.VertexConsumer;
- J g' A7 `9 v - import net.minecraft.client.renderer.RenderType;
" f% @, z$ j) o - import net.minecraft.resources.ResourceLocation;
( K. M8 V' g$ M) P1 |# L8 W! L, {
; D1 \) f# ~9 `5 e- import java.util.*;
$ M, z8 X. d* p; s0 h: i - # j1 l, i* O) |6 R8 n7 s
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(- E5 O* r8 \" j t& t2 E2 Q8 F
6 u" R4 I8 F% o: ?3 `6 ?- public class LineRender{! S- `, E, d8 p# A- ] p! t8 A- e: y
- private final PoseStack pose;; p6 A& M& ]* C( c: X1 n+ }
- private final MultiBufferSource source;) K4 i4 L: u) w% O6 @4 [+ K* L
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
7 B3 I0 U. z( U+ |2 \) v _ - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();; Q% b3 f9 f- r( H: ?& w
- ) ?5 @ L) A* j: w4 t
- " h. H/ }# D- |5 |0 Q" P
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
6 w3 }. m; K# ]$ @ - if(x1 == x2 && y1 == y2 && z1 == z2){5 ]: T2 `- w7 C6 w. Q$ g& r/ M
- return;
" ` W Z5 ~6 T" c - }
0 p5 }1 c+ x4 ~3 p* f - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){; C$ ~$ ^1 b/ n! e- `
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
/ I( D3 \# `3 t( S4 L5 v8 M - }
6 i" `& C; I7 h. y - pose.pushPose();2 Z2 G) A1 H [5 c6 |
- final int newLight = convertLight(6);
- M! ?: k8 F# o - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
0 ~' V/ U6 D: T - final float lineHeightSmall = (y2 - y1);
* Q' {8 U z9 f+ |" _( O1 H6 o - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
" E' s u+ S4 l1 o: T! W - pose.popPose();* a3 z6 j2 e8 E% j
- }
& T/ b7 S8 @' J, x1 n7 O5 p4 Y- s - # F: B8 o' S2 ]6 H
- private RenderType getLayers(String texture, int light) {
) W2 q( m: q1 b1 ?, i - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
2 y0 T$ ~" x) b& E: f, f9 \ - }
6 ^2 y; f0 h9 y y4 r. d - % m2 P% ~+ l2 ^$ z% {5 t. C" e. L
- private RenderType getLightTexture(ResourceLocation texture) {8 }& [& z8 }5 {4 P4 Y6 w/ P$ b+ y* i
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);- U4 c& g1 n' h" V r
- }
$ y/ i# r3 {2 @: S0 ]+ B) ] B( H! w
+ z; A) |2 O4 R5 O# D- private RenderType getTexture(ResourceLocation texture) {7 J4 X6 [6 ~) w+ i, L( n7 O. ~
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
( g; ?% O6 z, w% T5 I2 S' t+ [6 N - }
" A' S L! y& \: H& y4 k: I
2 O8 e0 ]+ `- X& B, J. Z% f- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {( f) x' l9 h0 `( r6 ^7 a3 c) ]6 G
- if (cache.containsKey(identifier)) {
* \/ |( @4 K) A$ v3 R% |. F% A - return cache.get(identifier);* F+ V6 k8 z; P9 `5 C
- } else {% ?. t+ w1 {0 _& a ^4 x
- final RenderType renderLayer = supplier.get();0 B4 K" R9 ]( p9 T
- cache.put(identifier, renderLayer);
' ?0 {6 r8 \. @& h4 @- Z. U) I - return renderLayer;
- v3 f2 @+ v6 R' I8 t - }
7 f7 }; [$ g5 ~2 b - }
5 e! w7 T: n) T+ ^1 x* t- Z5 P - }
复制代码 |
|