|
|
8 P4 y# C: |, j# C0 r5 ^) r
行,这个怎么样
; S# l9 {# B+ Z9 b& h1 C( N- package com.xhg78999.mtrfac.render;" G4 e( u1 a( b2 T9 B2 i% n
; Y1 L5 a# ~! D5 r9 g- import com.mojang.blaze3d.vertex.PoseStack;
* H# i6 I! n; [! M9 F4 W1 v# h$ i - import com.mojang.blaze3d.vertex.VertexConsumer;
: Y/ w# W; r) }* n: ?! M; B - import net.minecraft.client.renderer.RenderType;: a+ o5 f$ N; q- e8 C
- import net.minecraft.resources.ResourceLocation;0 V- z: m8 ?, s* W
- Q' S+ _$ x0 L+ L2 u, g5 A; W; c- import java.util.*;# U/ ^. O3 p$ T. L
; Z# w* q. j+ ^/ o x1 N( H5 ?- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(' h# Q8 t4 v) G/ x9 T C
; B4 j8 k2 w( ]) {' _- public class LineRender{
) V X& W) G J - private final PoseStack pose;3 B( J# i" ^! m) N1 Q- h" A
- private final MultiBufferSource source;5 p( z, s) N. E! c- \. P
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();3 u. q' p8 e4 ]4 g7 Q( R; D, A
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();, [! ~3 [! I0 t8 H5 r' K3 m X& y o
" \8 f; g! u* T* A1 O- * K7 V% z; w K3 F
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
2 f8 v9 J% _1 Y* s# h# N3 |3 ] - if(x1 == x2 && y1 == y2 && z1 == z2){
: Y' ^0 C* m& t* f# d1 o3 w - return;
: ]! E6 y/ w, M: B' j - }
$ d. Q I9 B N/ t& p& H3 b, H - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
+ q6 j1 ]9 d1 o - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");" V( t' J; a7 n- {" K2 ~' U' I# p
- }
m# o) L% u$ \ - pose.pushPose();
5 F Z& g# `: O2 o3 M: \, y+ J - final int newLight = convertLight(6);
4 d- Z: E2 s5 \( g: o& \ - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));% k/ E, |0 d8 [5 b/ Q' Y
- final float lineHeightSmall = (y2 - y1);
$ k C+ K: U! g- _+ n, H - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
1 i5 L: F) ^2 h/ C - pose.popPose();$ a( g- o1 o, ]5 M7 X
- }; ?3 K4 m+ ]3 D" J- Q4 h! J
- * j! {- ^% |5 v- `# p- x& Z
- private RenderType getLayers(String texture, int light) {
4 s- e6 e7 ]& z% ?: I' a - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));9 \1 K" m$ e, K. f
- }8 w: C- c6 r7 ?7 ~. i7 L! I
- ' E+ W9 V/ i$ E
- private RenderType getLightTexture(ResourceLocation texture) {& O" w C/ j: j0 W
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);5 M( a' U/ r( `; o
- }
) z9 ]# m, A: u! n- W
& n5 Z% d7 J6 e2 L$ {* E- private RenderType getTexture(ResourceLocation texture) {1 v( Q$ d- V$ e2 E) O" u
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
2 s$ x' P2 L. ?6 O: x+ S% o+ } - }1 D( e; {7 \) S; F
/ M4 F4 Y7 p0 N0 _. v' {% X4 S( ^! l- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {. P5 w1 C I' `: R y& p5 n; V
- if (cache.containsKey(identifier)) {
* U+ e+ f, }4 E H3 Z - return cache.get(identifier);
' Z" K) M: X9 p7 v/ _ - } else {
5 R( B6 X, l' I3 D - final RenderType renderLayer = supplier.get();; e9 F9 k0 d& u7 S- P
- cache.put(identifier, renderLayer);/ s1 M: P5 @$ _+ f
- return renderLayer;
; R/ ~( f2 a1 u3 u - }/ g2 b4 `$ B4 G h( N+ b) v
- }
) e. x# _8 ?" g3 V$ ` - }
复制代码 |
|