|
|
' u# b; s* m* j/ X& M
行,这个怎么样' H( V# S$ e1 r R: X) a
- package com.xhg78999.mtrfac.render;; d: I) L1 L0 B( M$ b8 Q
- 2 f) H0 T0 \7 E) `: _1 i: Z8 N- x
- import com.mojang.blaze3d.vertex.PoseStack;4 q# p4 C' q3 M! Q
- import com.mojang.blaze3d.vertex.VertexConsumer;
0 ]% W2 f1 M) g3 C4 H - import net.minecraft.client.renderer.RenderType;
' [+ z- C, x2 _ - import net.minecraft.resources.ResourceLocation;
m! D4 m+ Z; k# b. Z6 c) V - . ^+ @& w& f# @7 r: u
- import java.util.*;; O* c9 `; G( P" V4 @
- + }% n3 d( ?# e- g- l$ u
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(' a' r H, r) C+ r
- $ Y2 N$ Z7 H* X K) N2 J
- public class LineRender{
4 m. |# [) y1 b! E - private final PoseStack pose;
h/ x: b; f% q3 F - private final MultiBufferSource source;
) c9 B. V+ G H& H - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
9 T, R" H8 a& l# a: b - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
5 ~- ^; A/ L7 o, U% H$ C/ U - F/ Q/ s$ g& @* D& b3 y8 Y# ^
3 {$ l ^, {. y Z- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
3 i9 s7 L6 Y9 f: j - if(x1 == x2 && y1 == y2 && z1 == z2){
, L- K4 n4 k9 @1 i - return;
& @6 o. A# [/ F' V" L9 w/ u& V - }
4 t+ P4 ]$ h% }+ c& c, t - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){" Q0 M7 i+ }6 E3 M- U+ E2 z
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
/ G8 J7 v8 R4 |; _. D6 K% ] - }+ ~/ {6 a4 `" A3 t* [( Y
- pose.pushPose();
& T& S1 I8 H3 k, f6 K - final int newLight = convertLight(6);
9 L1 |/ z# }) o" |* X - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));; z( e O. Z: Y' [: n6 X) ^
- final float lineHeightSmall = (y2 - y1);
& p) K5 Y9 k" I - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);" B( Y& P' A0 Q! X2 Y. }
- pose.popPose();% z- i1 E P; F4 Z/ |
- }+ Q/ f7 t% @7 g1 Y- ~- b0 ?
- / c R. F( j; R6 `7 S7 q, T+ \
- private RenderType getLayers(String texture, int light) {) _4 s8 j y5 D- v7 d5 W4 _$ F4 _' F' j
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
$ O/ y. D6 c; Y; t% ] - }+ _) f( B: t9 V4 e% b" y. O. x/ l
- 8 Y" E' T, T! `& @8 F4 x" c J
- private RenderType getLightTexture(ResourceLocation texture) {
* R: U K5 }" H5 O2 E2 w0 s - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);" D: j% F7 j( y: J2 ]
- }
- ~/ M5 ]' ~' l- s3 H7 R4 H
! S" X" `( U# G2 P9 [; ^ \- private RenderType getTexture(ResourceLocation texture) { v8 z7 ?5 q1 Q
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);/ c. A! b4 T3 I/ U+ z
- }% |& {: }) ?0 a2 J+ c
, y! |, h) i, P9 m. R. W% H5 o( e- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
; Z1 _& R% H8 V$ k( z& Q - if (cache.containsKey(identifier)) {
& {+ }9 N# O0 k' b - return cache.get(identifier);
' n5 [; a2 a3 M. h/ I - } else {+ S& S1 z. u8 n. S
- final RenderType renderLayer = supplier.get();
3 H( ]- S, P# L5 Q: ] - cache.put(identifier, renderLayer);
8 u4 H: w6 Q# g - return renderLayer;5 |2 u# A& v7 n& S+ C$ J1 r6 E) U7 B
- }' f, M$ f2 p( i. G! v3 W. ~
- }
/ N; J; u8 a$ i- A - }
复制代码 |
|