|
|
+ r% ]# P( `/ n) B: X2 v+ B
行,这个怎么样
' l9 Q2 l& \ d6 c) x- package com.xhg78999.mtrfac.render;6 r! ^" o0 v$ c$ x: i/ l' N
3 w8 U. ?/ u- m, R+ U7 S- import com.mojang.blaze3d.vertex.PoseStack;
' l& C$ d& g9 ^! n2 \7 _1 v% M% m1 z - import com.mojang.blaze3d.vertex.VertexConsumer;
: j1 v/ F) p6 o; a) ]) P2 t" X6 P - import net.minecraft.client.renderer.RenderType;
8 U: p: X% p+ D O) q - import net.minecraft.resources.ResourceLocation;
( L5 |5 _9 [$ Y( G% c4 q/ Z - 6 H& v9 P' `! w
- import java.util.*;. g8 m L, ^, V* D% {5 d
- 7 @. h. c' ?# K) J6 f! t
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
3 ~4 K& p8 q/ X# n/ ` - & Y7 B2 z" g* h/ H) T, y i% h
- public class LineRender{
1 k' S0 M8 Y$ ^) j5 H( j9 l - private final PoseStack pose;
6 X2 `) b0 ~$ V1 e$ n( d" D - private final MultiBufferSource source;. F; g2 v u5 j1 Y
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();2 w/ i0 U: X7 X( I8 }
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();0 E6 m+ \- t W$ i8 z" E
0 f7 e5 N" n! H/ }) N+ y- 2 q B' m0 |: Y' R$ L
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){( Q, ?) S: v1 {# j# m' Q8 f
- if(x1 == x2 && y1 == y2 && z1 == z2){
7 `7 N8 S N- I) y - return;
$ O3 A& D0 g3 V I; | Q3 j - }
4 H- @9 ]. n( r - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
, J. h% x) O L+ a, M+ U) m. P( H - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");. m. v8 [& [6 O7 h* l0 g: p V7 ?
- }" D* t: e1 e) e
- pose.pushPose();9 p8 M: Y3 k: `2 r5 W; Q
- final int newLight = convertLight(6);
- U' p R! c$ [7 D6 m. r9 P - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
" q; _: e* ~4 M* ]- g# X( O& U - final float lineHeightSmall = (y2 - y1);, x) O9 f) Q" Y$ h, z4 I& j
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
8 @: V+ S! _8 J8 Z# e4 P0 d - pose.popPose();5 \/ M. v- I# I4 ]: ]
- }" Y% B, Q( M5 t3 A- k
- ( \( {3 o1 E' F& N2 e
- private RenderType getLayers(String texture, int light) {
7 J W: @0 ~1 s. a - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));( X1 e. V5 Q. R* ?. l; y5 v
- }" d- z. P. L$ Z$ U) k @7 V
2 A7 Z2 L. n6 W$ `4 ?% d9 m- private RenderType getLightTexture(ResourceLocation texture) {5 M8 H2 W. {2 ]8 ?9 w- d9 t2 H% u, c
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
# R8 W, r, `/ a - }
2 m( }& T8 k! i- p7 s
4 i1 a+ w0 ` b8 f- private RenderType getTexture(ResourceLocation texture) {1 G+ }1 ~1 R+ _. ~$ s, b4 ^; K
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
& V5 U: ?0 N( j" _6 E' E& O$ a - }
9 ~6 _! f" s$ ^: s# j, G - 3 _& D" l" W$ ?) P4 B
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
$ w; i- W, E7 J1 y" l - if (cache.containsKey(identifier)) {
% Z5 y7 {# f0 ?6 P6 q8 G - return cache.get(identifier);
. h& m5 c2 E& I+ M) w2 q; {, n+ x - } else {. R$ G& p( q+ g) X" S& ~' T
- final RenderType renderLayer = supplier.get();
8 \) l4 R5 p2 m3 V/ Y8 ~( ]( X$ a3 c - cache.put(identifier, renderLayer);; ~" P. e; L7 s1 S
- return renderLayer;
/ _9 J1 i7 ^) ~( b7 J6 v2 @ - }& V) T: ~( X8 _6 X
- }
, l+ [1 c$ g) t5 ^& A$ H- \ - }
复制代码 |
|