|
|
! h6 r$ c" w- A# A/ h8 z: O
行,这个怎么样7 J8 p! u$ B2 G4 f' v; f7 C6 Q
- package com.xhg78999.mtrfac.render;
$ N- f1 o, h* G% } - + l7 ?, L& |; N( A r) l5 X# \. G
- import com.mojang.blaze3d.vertex.PoseStack;1 h- A5 I" r ^! n9 \2 }7 d# v$ [& L3 |5 U
- import com.mojang.blaze3d.vertex.VertexConsumer;
& y0 ?" x) C5 o% H. v - import net.minecraft.client.renderer.RenderType;
+ \4 B$ f# ^3 i! y4 F# z, o - import net.minecraft.resources.ResourceLocation;3 w# R7 n4 Z3 Y% r8 X
- 8 \: ~4 @: m1 [; i. q
- import java.util.*;/ S' {# b* w% Y
- z3 A Z6 j" Z4 x8 |8 a
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
4 x. L- p- k5 C3 m# @4 i - 9 i& d$ C/ N9 q
- public class LineRender{0 v9 k3 }& y7 Z1 B
- private final PoseStack pose;) N5 o+ \/ n8 D- u' `- j5 P
- private final MultiBufferSource source;" M% n8 p5 r3 a" R$ G
- private static final Map<String, RenderType> CACHE_A = new HashMap<>(); J h$ j9 W+ c/ |, o2 X
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();) s, @! G. K* a8 c
- 3 x& `" i* k7 T1 S( H
4 |* T% Y' r1 b1 v8 K& Z- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){9 ~, \4 _+ `2 z! @# Z
- if(x1 == x2 && y1 == y2 && z1 == z2){
2 P d* G+ Q& a- d; B) ]/ d - return;, j: m' @! ^, Z
- }
' D- b0 s3 D9 d, r) y - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){/ b, { f, P3 l9 `0 v, A. y/ I! T
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");, R4 E% s8 q7 }0 t+ ?7 w
- }2 H. \, H8 m2 u- y3 U
- pose.pushPose();/ B8 o+ G8 q) t
- final int newLight = convertLight(6);
- u" s5 l5 b& }! \& ?; d7 Z3 E2 h - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
' m& G! y% L A; Z1 ? - final float lineHeightSmall = (y2 - y1);
5 i4 z3 x) W" l- d" K# B - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
- Y7 a: H) V1 E: q& F( g - pose.popPose();
' ?7 H- n) Z1 l* C - }
; q7 a# \7 U/ l; r1 l - . Z4 ]8 T! n9 Z# m6 c
- private RenderType getLayers(String texture, int light) {, m" G8 @& U1 m5 D+ P0 }
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
8 M% R! L6 G4 M& \9 F* G - }
$ Z3 a) R+ }$ t! D7 _ - , m" a6 \6 d" f% ]
- private RenderType getLightTexture(ResourceLocation texture) {
* U' N. k* g. `# ]; g - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);8 `$ ^8 Q$ y: J; m/ C% M; ~
- }( V3 n1 z4 O2 w: T8 J: S' u
E6 w& u! H: X- k0 U7 m8 l- private RenderType getTexture(ResourceLocation texture) {0 Z1 e7 Y) c5 P' Q4 V( G7 D% L
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
0 s+ f! v1 U2 ]% ?; O - }
) q0 Q) H. l9 n8 S
6 f! C1 U _% e( K9 q- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {9 C8 d1 [9 G" R9 U" Z' ^ {* F
- if (cache.containsKey(identifier)) {
' d' M4 R2 n" O. e. j: K - return cache.get(identifier);
5 L4 V& Z/ A2 L3 C5 c" ? - } else {2 Y. R* F# D, t# s! ]
- final RenderType renderLayer = supplier.get();
* B9 ?) { `) g; E1 t: j - cache.put(identifier, renderLayer);: i: t: [/ @$ T) Z
- return renderLayer;
; B* l5 L9 r1 a - }
7 w! f" n0 t; h8 D! L+ v - }
0 V+ S8 C6 W$ L% C9 n3 { - }
复制代码 |
|