|
|
' ~. I. v/ T1 [! ~1 S- ?; I( |
行,这个怎么样
9 f2 a! q8 t* C! b: S+ `' t& m- package com.xhg78999.mtrfac.render;4 i3 ^, c) f. }6 T" }' ^. ^
) v2 a% H4 @1 H b2 _1 S( p# s( a6 I- import com.mojang.blaze3d.vertex.PoseStack;
$ B$ q4 P* |, v, E5 W - import com.mojang.blaze3d.vertex.VertexConsumer;$ ^- I8 Y2 [/ M& d" c6 m0 ?
- import net.minecraft.client.renderer.RenderType;. I, ^! `3 F( q l Y; }6 V# B
- import net.minecraft.resources.ResourceLocation;
$ r5 K7 D! |1 r& l+ u* w. U# r1 @0 E - * Z$ r+ C' z9 u+ X( [
- import java.util.*;
# n+ v5 \+ m9 c6 o
7 H- T/ T8 S, X+ m" x" M/ F/ D- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(1 ~! w: `3 N/ A
0 M8 w, l7 O1 k9 F; U" w K- public class LineRender{
- Z: p: ]# L" d0 O - private final PoseStack pose;
$ [8 D3 j# k3 `/ r$ ` - private final MultiBufferSource source; m1 G9 ~2 |! m# u8 n
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
, d( s8 q5 {- I& V - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
& v- L( B2 o7 n |0 P6 g - ' L, W$ E# D8 f
9 e8 i$ S1 j _" {* u- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){! w d8 L0 F6 k o# { N
- if(x1 == x2 && y1 == y2 && z1 == z2){
3 w+ u' M1 _: P9 V$ k3 B - return;
; ^% P# V- k7 ?3 Y6 t3 z- B d - }: r0 W5 s5 m5 `( z; `
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
6 f6 c3 C" k, O5 k5 C - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
- Q. A( {' Y5 q" X* Z, ` - }
4 ?8 d3 @2 Q2 e5 S - pose.pushPose();$ d$ h8 ~8 [2 S( ~$ b) u7 n, C
- final int newLight = convertLight(6);- P" C+ r/ N! @% v R0 O
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
# D( X0 B' K8 \, u: q0 L$ v - final float lineHeightSmall = (y2 - y1);
$ } T4 O; T! ?8 s7 x0 O& Y - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
/ {' G1 \ M4 w4 L: W; N: | - pose.popPose();
/ Q/ i! [4 W; P4 k - }
, I6 T1 N: K/ G" G3 R: e
4 B( \- ^2 k5 Z2 @# T3 U- private RenderType getLayers(String texture, int light) {
4 |7 g6 a p' Z" n+ z/ w, a - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));) L, M; E+ \2 r! i/ z5 B6 v1 S
- }
' @% x, {# x4 G! ?! `( d - 9 U, H$ ]- f6 ]( b
- private RenderType getLightTexture(ResourceLocation texture) {% G4 b0 U- r, p% d; [+ @9 [
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
' q) l- U/ y: e$ R3 O8 j8 f - }9 x9 Z! A: w' k$ e9 t. x# h) D0 e: ^4 @
- * W7 q. ?2 t# w3 Q f
- private RenderType getTexture(ResourceLocation texture) {
/ W: U. }# n9 h" K" p( z - return this.cache(texture, () -> entityCutout(texture), CACHE_B);( G& a! `/ [' `, A: c/ N- g7 r
- }
9 ?3 w$ M# }2 | - + q, [) _% v$ A# q6 `- Y7 e+ b7 |3 [
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
5 Q' r' f x( g) e- M' R0 A - if (cache.containsKey(identifier)) {/ [# w9 C7 U P0 v# d: P
- return cache.get(identifier);
- q& l9 T; H1 { - } else {! a* B" N, e$ h& U; ~; o
- final RenderType renderLayer = supplier.get();
! v$ ]7 D' X+ c* d6 @! b - cache.put(identifier, renderLayer);4 p* K: r* f: T2 E0 P' C
- return renderLayer; v2 C- Q* q0 N
- }6 U! a7 M9 W( F' t
- }
& _1 C4 Z9 ?( m2 q - }
复制代码 |
|