|
|
* V9 I* K8 [5 |) y3 Q
行,这个怎么样: J/ t% O6 ?) d8 c; H5 w) h; x# w
- package com.xhg78999.mtrfac.render;
( L V: }7 E: l3 b
+ k S2 x* J. M$ M# H' E! W4 f- import com.mojang.blaze3d.vertex.PoseStack;+ C$ h' O: y- M* t* \% B2 x
- import com.mojang.blaze3d.vertex.VertexConsumer;$ Z) U2 O" {( z9 s' l5 C% E, Y( U: i0 b
- import net.minecraft.client.renderer.RenderType;
' v6 _4 E; a" T, T z7 F - import net.minecraft.resources.ResourceLocation;0 a& H% b* S L+ E
) T2 E% z+ O: D, ?" [7 V0 O- import java.util.*;2 p# a+ n* R4 |) _
- 2 B% q7 j8 \0 f* M2 M* j5 y2 g
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
0 j3 g1 u6 @( }; J0 A
& U7 C3 J3 ?& }0 g5 f- public class LineRender{
+ c. d( G* w3 q5 a0 a - private final PoseStack pose;* K0 Z' ~& a' [/ ^
- private final MultiBufferSource source;6 e8 f ~4 _+ X) F! c' h2 W' H: c
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();3 {' m6 _* D! w; _4 r
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();; {! _4 f+ I1 ~% _- f' B, D3 ?+ Q+ r
- ! z; {% h6 {8 D! X
- $ Q( ~0 M5 h6 Y4 E
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){; I4 f- _# d: t& g
- if(x1 == x2 && y1 == y2 && z1 == z2){
) {. N1 I4 |* ` c; J9 W1 H - return;
2 n1 l& [3 Z2 T! L# Y D - }
7 a) ?1 ~5 ^ p - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){# ^* L% @3 B) J- ]
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
3 K# c# h3 _: h* [9 P' { - }0 b* w7 H+ X- G
- pose.pushPose();8 P$ R1 l1 C, j
- final int newLight = convertLight(6);
! R; n: m3 Z* b" ~* ?0 @ - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));& W7 t- o7 i4 A4 \
- final float lineHeightSmall = (y2 - y1);4 e! q( D4 _" ]% L& A( }
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
, k9 B5 a: t' M* W$ g - pose.popPose();
; B% d- a) v* Z0 U" y7 S - }
- A% w Y' @- F0 ]& t) H - ! p4 `) B* ?, k; i& {
- private RenderType getLayers(String texture, int light) {( D% N4 c7 e. ~) f
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));3 `( B0 O, W3 i! E- X- ^* y4 {
- }
' c! e5 k* g/ V Y5 i8 \
! @1 I5 g2 ^- p' g) \, L, I) e- private RenderType getLightTexture(ResourceLocation texture) {
* x9 a0 A$ K- R w% y5 i7 r4 w* H - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);0 M- }7 ?( f) r8 E" K# [: m6 [
- }/ r2 N/ k# O/ w1 y) s
- $ O# O% M; o% B2 C
- private RenderType getTexture(ResourceLocation texture) {
0 } e) g& _0 u% a& d - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
0 f: u% x( m1 A1 O0 w4 f - }( F* ^4 U/ w, g
% B3 x( l+ x% W$ x- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {! D. t1 O$ r7 v' L3 c! a
- if (cache.containsKey(identifier)) {
/ j5 d, M; H9 P$ m - return cache.get(identifier);5 U3 a* B( h q& O$ Y
- } else {
& g! S. C5 Q& J& s6 e - final RenderType renderLayer = supplier.get();/ Y8 o* K" u+ Z) A
- cache.put(identifier, renderLayer);4 u. Q& [" @; K' ^
- return renderLayer;) e# k3 ]$ O8 J- [ ~$ a8 b
- }: H$ m. ~0 L. G: `* L+ i/ m3 x
- }
8 Q! m0 M5 n {1 V, g - }
复制代码 |
|