|
|
B7 B4 @8 w% A1 W5 B3 L; r' ]
行,这个怎么样2 O# s" b: e' f. U
- package com.xhg78999.mtrfac.render;
3 f( E5 m3 g6 x& B
4 N( p. F6 g) l( J) p, D8 p% b; A- import com.mojang.blaze3d.vertex.PoseStack;* R9 Z- l5 ^! O% |, [& N% T4 t
- import com.mojang.blaze3d.vertex.VertexConsumer;
: s* ^6 e1 D: O; v+ e - import net.minecraft.client.renderer.RenderType;% W- t+ N/ i& M* P$ d2 d. o
- import net.minecraft.resources.ResourceLocation;
8 A4 {: c- n) P g' {
' I( @' K U/ I: W- import java.util.*;
; @4 m0 ]7 ]1 A9 I& h7 U. E
. t2 ^0 f+ m8 D4 ?- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
& e, b6 Z; O, v$ b
: N! A5 x- j+ M$ x' C- public class LineRender{
7 g) Y. B0 W. X1 M0 S) D. x - private final PoseStack pose;
/ i+ M0 N/ J. w+ m. y6 K v* K - private final MultiBufferSource source;
8 H8 c) d/ _+ a- u9 [ - private static final Map<String, RenderType> CACHE_A = new HashMap<>();; O$ q( u* {. t9 s7 T
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();/ a8 m- ~1 s" T% }9 E9 @2 ?
( N, G3 {7 L; c# X b5 c! [- . O' V7 Q$ J# ]8 Q# m
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){& D' h2 Y, W0 H! p6 U" U
- if(x1 == x2 && y1 == y2 && z1 == z2){' E" q: A8 {) l
- return;
7 Z! T" S# u$ K0 v3 Q4 p' e. @ - }
2 e) M1 b; H5 g! N: }# ~3 q - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){1 c. F" K0 }# F- k
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");" {+ K. ^; a5 R/ c) D
- }9 Q5 U' o1 F$ W/ h* i/ I8 S
- pose.pushPose();
; [% C! |9 _, k' Y - final int newLight = convertLight(6);- \4 _! f0 j1 R+ N" ?9 V( z3 |8 f
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
9 S$ K) d8 E6 ^6 v3 A. |, Q% G - final float lineHeightSmall = (y2 - y1);
2 K* C: Q* D" H) {) X - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);6 d. I5 C' M7 H' b1 Z7 [
- pose.popPose();, y% ]. u' j/ s! Q) ]
- }
/ q# `0 S2 N& {- {6 ^ - 7 ]2 D" S4 }5 o0 |6 z# Z% a: g* c
- private RenderType getLayers(String texture, int light) {
" n6 ?+ a. F+ E0 o+ a8 z - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));. e5 D4 J3 G% d3 t. `
- }' |% T$ ^0 k, C& J! h
+ E: {0 I4 g+ Y2 O& x1 W$ O- private RenderType getLightTexture(ResourceLocation texture) {& f! f$ {% f0 |% T
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);, x7 q; Z; m2 ?7 p% o* |3 y) c
- }
9 S' Q1 m3 j( _, W) V, C k' t - 5 g, X4 o ]7 [( W# p+ P0 _1 Q( C5 C
- private RenderType getTexture(ResourceLocation texture) {: L$ c! d/ Q1 n- {' \
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);+ X9 m* c9 F8 D" k% Q F1 [4 B# _
- }5 i& J6 l( X% I5 R k* A i
- ! Z7 y9 M+ _9 J0 _
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {, H8 S& A/ t+ q3 q
- if (cache.containsKey(identifier)) {! t5 ~. y' }& d7 s3 l
- return cache.get(identifier);
% Z' \; g: R: J6 N - } else {
7 {$ v/ l6 y' r/ i - final RenderType renderLayer = supplier.get();5 p" T! ?( w4 z( o2 i! e- {! w7 x! M3 a
- cache.put(identifier, renderLayer);4 d# G, j8 ^/ T7 j" C
- return renderLayer;
" d$ |9 N$ @# }6 Y% W( R - }
6 i' p) i! O' Z - }2 `1 [9 ~: `4 M, ~( Q' Y
- }
复制代码 |
|