|
|
+ \" v$ v' ]+ C# S. Q3 c行,这个怎么样, |+ x" n' @6 X6 r
- package com.xhg78999.mtrfac.render;8 J, @* L5 ?5 s7 o; Z! h+ E
- - O$ G1 y8 b5 [$ C& d
- import com.mojang.blaze3d.vertex.PoseStack;8 T, F/ {5 A Z- T, `! a6 J" Y+ M5 ^% ]
- import com.mojang.blaze3d.vertex.VertexConsumer;
3 E) f8 R) ~: v. ^% h9 K: w - import net.minecraft.client.renderer.RenderType;
/ s( x) \+ f1 L' X, q - import net.minecraft.resources.ResourceLocation;7 l! u& M, q( n5 {/ T- o1 x. }
. ^7 e8 A# q. S* A- import java.util.*;
6 Y0 t+ C% e' q# C - 4 y' H% _( d6 c7 c
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
4 p6 A9 o6 E, Y8 ]% ^8 R! U$ J, Q - 0 k7 ^% R# I$ A0 o0 c
- public class LineRender{& C6 L* U/ ?4 }* B8 r. U4 M2 p
- private final PoseStack pose;0 n. }: L& @& F w- g
- private final MultiBufferSource source;
5 A6 B0 i1 i' D: v+ }( N& [ - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
9 q% {6 ^5 `5 q9 y - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();, w( J+ G- [0 k2 a9 o1 R
- # | {2 ?# i. t0 c4 [8 ?; S& }+ k: M
q* o8 V1 G; A8 L# B- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
3 r" v% {0 G0 h Q1 X - if(x1 == x2 && y1 == y2 && z1 == z2){7 m/ R H& }5 U" W. y
- return;
w1 d" A0 N& B8 E - }
- ~4 \6 X% B9 @3 G7 h9 x - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
, ^+ b2 n/ g, g/ } - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
+ [7 X4 Z* F$ S - }
. z, T/ Y; m1 n* s% ~) | t - pose.pushPose();. `5 m* [* A$ c
- final int newLight = convertLight(6);, m- q2 ^0 T( U+ }
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
7 |) X. e @+ b4 F4 R8 ]/ h - final float lineHeightSmall = (y2 - y1);2 F! z5 @7 u' E: g' u6 H
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
& f6 O( l& w: Q Q* V$ g, E4 D: Y w, o - pose.popPose();
6 \6 a& X6 g5 I/ V) l4 B4 L - }
+ @% `3 Q0 V1 Z7 W - , U) |. T+ v3 Y0 f2 F# g3 b
- private RenderType getLayers(String texture, int light) {
* e5 y8 ]% \7 I% ?" c/ `! u5 S - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));6 g4 H3 i( o X+ S5 E
- }
+ }5 _; j0 T. @" K6 T( m
* L/ X% C4 A7 N: @9 m, u T* [6 Q- private RenderType getLightTexture(ResourceLocation texture) {
2 B l( ]% K6 r4 C4 u% Y - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
( ^& H) q n5 _* Y3 D( |( g - }, j/ N6 j' N' p9 n5 }. U7 d
+ {9 C! p/ ^# i0 \+ ^" _2 u- private RenderType getTexture(ResourceLocation texture) {
8 {& @0 [3 t; V Y7 D - return this.cache(texture, () -> entityCutout(texture), CACHE_B);6 V9 L8 E" o1 T
- }8 K) t1 F' f3 Z+ C6 O! C1 b4 w
4 z5 ? m; `( O' S a( G5 Z- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
3 V% h- z F' Q1 m - if (cache.containsKey(identifier)) {
4 p+ |' M: s9 N3 @ - return cache.get(identifier);5 G- v; t. Q& h/ q2 {2 _
- } else {
& U: _1 V+ Q8 k1 t) P - final RenderType renderLayer = supplier.get();4 \/ L6 I6 G& y* N
- cache.put(identifier, renderLayer);
1 Y- T5 T& o7 [0 b; U - return renderLayer;! q j+ s8 R) V- s" i m% `9 ^
- }
5 I6 f# K& J" x5 z2 p" g - }
+ L7 A9 Q' j% d, E - }
复制代码 |
|