|
|
4 q$ L- c2 m' ^7 q9 k# Y9 e) `2 i: `
行,这个怎么样% A# o# L1 I" z4 p8 e& n% {) y' r
- package com.xhg78999.mtrfac.render;( @) f8 b+ }$ B, w' I* R8 h' t
6 j7 A9 \$ j/ F; K$ F+ Z+ q- import com.mojang.blaze3d.vertex.PoseStack;
: E- V2 S- r7 ]+ x+ G) @ - import com.mojang.blaze3d.vertex.VertexConsumer;- Y" D9 h4 x9 ?* |3 s4 P( S
- import net.minecraft.client.renderer.RenderType;$ u( p0 L( R3 n
- import net.minecraft.resources.ResourceLocation;
% c( L+ M3 e; C9 I8 \
, Q$ A) {8 l0 c# m& Z: v6 Q- import java.util.*;
( S8 q6 X g7 [5 G$ `) }1 d2 o6 i9 ]
+ i. W1 A# u; v" N2 o- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
; R2 y* c' t. n+ u) J
, ?" V, Z) ~4 B- public class LineRender{
# f* e/ H4 y! x" Y2 U - private final PoseStack pose;
/ ~ L5 ~% b' Y+ l a; _ - private final MultiBufferSource source;
, x8 S/ k" O+ Q9 d1 X% o - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
- W$ }4 Y& H+ N, _. t2 T- ~ - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>(); U5 L9 ? _# W" y) j
- 7 l- A! o; A5 {. T; g: ^& ]
- . z$ W; t" r5 t0 T3 b# _7 z0 ~0 Q
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
7 O3 m- B- A. h- d7 R - if(x1 == x2 && y1 == y2 && z1 == z2){
& b' @5 @" l! M9 U3 G, G# I4 B - return;
% p8 Z' Q( d# g$ w# r( g - } D6 D8 y( p& X; `0 v$ k
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
1 ^+ ~! I7 s' t/ a9 n) x - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");8 J4 r: z: u8 k' h v& a
- }& a5 d2 _6 o2 Z! {$ f4 [
- pose.pushPose();7 M* u7 m. j! Z5 ]( G
- final int newLight = convertLight(6);4 g- S7 e4 E' K! X; P
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));% l( h6 g" {) W% P
- final float lineHeightSmall = (y2 - y1);" G% D. }2 m7 w& Q
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
/ h" |& q- S3 V, ?3 g2 R - pose.popPose();
7 c6 Y, E- \( ` - }
9 @3 p- A* S& }" \, a - k8 J3 `5 D( b/ x4 Q( i) N! d% T
- private RenderType getLayers(String texture, int light) {
& w3 {; x3 \0 T- ] - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));! f" S9 _8 G4 d' q
- }9 D; h6 F3 B' g* O P: u2 x
) {# E" s: b0 G1 J# `- private RenderType getLightTexture(ResourceLocation texture) {7 ~% u7 B! l# H# W5 s
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);0 c+ W& y- P2 t% e5 C0 y9 D
- }
4 X. \, {, b. R; @: f1 M& a
; ^- {* X3 J3 m7 \3 L+ h- private RenderType getTexture(ResourceLocation texture) {
( J y) |$ y" z1 E' m) T6 o4 F* u - return this.cache(texture, () -> entityCutout(texture), CACHE_B);; Z3 X; V O2 `& @1 |
- }
$ [8 T, l o% W5 A& A - 4 a! b& g) d0 G; y
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {* B; T2 D& Z! L! K6 u
- if (cache.containsKey(identifier)) {
: T' J* ^9 r/ e1 d$ } G6 [ - return cache.get(identifier);
# o% i( t2 @6 r: ^/ A) i3 F: t8 k - } else {
! P4 ?. K3 {; s/ }* ~' V - final RenderType renderLayer = supplier.get();) O0 F/ V& P8 I# O, r; D6 n
- cache.put(identifier, renderLayer);+ |) S$ C4 t% X; ~# e
- return renderLayer;! m& U2 h. k% v5 g0 U( k$ M
- }% I, {! v+ W+ r3 g
- } A! S( a" Y, u' b/ k8 i( G8 g- A- S
- }
复制代码 |
|