|
|
! v8 h1 r: J- c' S- S- z! J7 J; k
行,这个怎么样
# n2 ~, Z! E+ h, G( E# C8 y- package com.xhg78999.mtrfac.render;
( c# r* q) [" q$ V
/ T! |* R! e4 x j6 o, @- import com.mojang.blaze3d.vertex.PoseStack;
* {7 g% m1 U2 r# ~; m: a$ w. O" E - import com.mojang.blaze3d.vertex.VertexConsumer;1 F: X1 i4 G8 T$ `. u; Z. G
- import net.minecraft.client.renderer.RenderType;
+ G/ A$ V, i6 @% u' U - import net.minecraft.resources.ResourceLocation;/ G' g$ S1 T! v$ x
- 0 i2 }/ B( k- H/ m% `
- import java.util.*;4 _3 [, f' Q- ^2 y1 e: T$ Y
- 5 P$ S7 k6 p0 y- b/ {
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(; |5 K) O3 X; ]6 S
- 2 ]( ]; z6 U4 {: Z* e1 ]9 {9 @5 ] Y
- public class LineRender{
, s: \4 i& h1 h- k2 J - private final PoseStack pose;. e4 C$ V& D/ G
- private final MultiBufferSource source;
' z4 u' u( c% i" b# } - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
6 m$ w% {% ?% J" s! c, ^ - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();' y8 o& L4 T* {$ d
6 V0 i) _7 `! m: ~' p$ [
+ j: F4 C" P$ U1 b8 b- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
7 ] w6 P: W: s - if(x1 == x2 && y1 == y2 && z1 == z2){$ }( A) K2 ?+ l" n3 @8 O' M
- return;% z& \' j6 t0 r" G0 J0 Q# j
- }' d) S, X& g% h; ~ r. y) l
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
1 h6 K" p+ i+ @6 a3 d+ g4 Z- F - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
, {* P! E d/ C - }: E1 y" A F9 U
- pose.pushPose();
7 L0 S' A- T$ x+ x' `) B - final int newLight = convertLight(6);
5 k% j. U5 m. j B - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
5 q, e. ]" Q" x1 ` - final float lineHeightSmall = (y2 - y1);
" M0 H8 V7 l9 p - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);. s5 {% ?& U' I; v0 c8 c
- pose.popPose();
/ f3 y0 j' F: K' H, b" z - }
0 ^/ o6 R6 k( v7 [ - 2 ?" S8 |8 _, f B
- private RenderType getLayers(String texture, int light) {. `# A7 o* p. E X4 G( W3 ]' i
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));. K& z6 w$ P8 S3 X1 [3 t! o
- }
! g' {% {0 {1 j: }* E9 N
9 C9 v3 l O: r- private RenderType getLightTexture(ResourceLocation texture) {* f! J0 v7 D) y) v( a Q
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);0 Y+ A3 I5 z- V6 m& z/ f7 Z1 e2 Y
- }
! A' L& b9 ]7 w5 }" D- @; O
' Q/ n- q( v- ?' h8 n- private RenderType getTexture(ResourceLocation texture) {
+ a! _) o* j$ ?9 u; ]! } - return this.cache(texture, () -> entityCutout(texture), CACHE_B);3 M$ ^/ \# W" ~$ ~# m
- }, }5 O: n# q" l* @3 z# Y# n+ \* }
- " z! z1 c7 |$ L# B
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
2 D- d3 `/ l3 } - if (cache.containsKey(identifier)) {# v3 m# l3 S ]/ N6 y
- return cache.get(identifier);
7 l7 T$ @ d& |+ K - } else {
/ s" U9 ^6 Q+ Z* A" R/ L# p1 y" _ - final RenderType renderLayer = supplier.get();3 t% \; Y! q& S$ M7 h/ q" w
- cache.put(identifier, renderLayer);
8 u# k! C4 s9 N3 h) F - return renderLayer;
7 D+ y/ X, a- H) P) |3 c# d4 z - }
- z5 r/ P' [4 m* L. a - }4 q+ ^8 U' L3 V, x; {- F- \) c) P9 t( r
- }
复制代码 |
|