|
|
0 |8 w3 b% X# {
行,这个怎么样4 A5 x( a/ @4 U
- package com.xhg78999.mtrfac.render;
8 d7 p9 ^) s' {8 @ D4 o - ; h4 v* {* [- `" P! z/ z
- import com.mojang.blaze3d.vertex.PoseStack;
$ E# ~ t1 c3 E: F0 ` - import com.mojang.blaze3d.vertex.VertexConsumer;
! M+ \. h: _' b3 P* i- l - import net.minecraft.client.renderer.RenderType;, o: e4 e. Z ?9 Y
- import net.minecraft.resources.ResourceLocation;
* K* i: w+ m3 F8 g0 F0 J- n - . d- _# N+ a+ j- B6 A
- import java.util.*;
0 [2 S5 f; e8 s, @. V# _
! g9 u7 V# V. p! |1 K! V- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(! F8 _# ?; I' T8 k/ \1 G
- ! R; z- E# K H1 H) I6 f
- public class LineRender{
3 H' v3 w8 H! `5 h* Y* Z; ]2 x( Z: t- r% r - private final PoseStack pose;
$ y7 P- i P6 S1 N! r - private final MultiBufferSource source;* m% h, z N3 G Y1 c2 F5 n2 T
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();) X' D/ L6 O) G: {6 o
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();8 g6 x- c8 p; s& q: {
5 I4 w7 L: P( Z8 ]- 6 X0 J; D' ^/ p: f" l+ j
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
1 Z# G) t a9 Q - if(x1 == x2 && y1 == y2 && z1 == z2){
; y. q, w6 ^8 Q% U - return;6 L: b% u- T' y( o
- }
: O, c {4 p# J/ N ] - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
0 ^2 v- Z" I) i - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
. t" G/ Z5 w0 d( G% o - }+ B0 F- r6 M; g, E$ r2 U
- pose.pushPose();
* Y2 u' `' [) B% p4 a3 u7 Q; v - final int newLight = convertLight(6);1 M7 A2 j9 G. ]+ q/ i6 r
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
* m7 g% v1 [8 o3 O5 p - final float lineHeightSmall = (y2 - y1);
* i: l! j' Z1 N3 K4 \ - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
0 N3 j( Y: D0 m - pose.popPose();
/ T0 Q2 W. a$ a& o. P; N+ B - }; t& T6 z6 n: E1 e) b1 w& d- L- k
3 R ?8 @' o0 Q; K2 \) E- private RenderType getLayers(String texture, int light) {
; e. H, v, t0 h - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
* \* ~" ^! S: b, v - }2 T6 ^7 R, c, B( M% T& @* c
% r* ~; ]; x; z! h- private RenderType getLightTexture(ResourceLocation texture) {9 r% X K9 l: o6 z
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
, o. X$ r9 }4 v1 W% h/ {* Z - }
5 g& a, {, s* ^+ |: i+ w# }: z' c
: S2 E; _8 d2 q3 [, \" [. g- private RenderType getTexture(ResourceLocation texture) {7 r) z a2 y- p# _& s
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);5 [8 q+ V' x- K$ i
- }
) F) W" c; a7 {8 |& j2 j$ b- a - - Q7 g$ b- q3 g6 b; K) L ?
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
- ?& Z! h) Q. f: J) K! ^# \ - if (cache.containsKey(identifier)) {
+ r V" U% s% L0 M" f! W - return cache.get(identifier);' v9 B. |7 l" f5 R* T6 z
- } else {
7 {0 P+ ^( A8 h - final RenderType renderLayer = supplier.get();
0 ^/ G+ H, x1 ^: l8 [2 _2 m - cache.put(identifier, renderLayer);
7 F5 n: a3 r7 ]) c' \; p - return renderLayer;9 j3 b- {8 E$ U% q' N# }& E
- }6 s: S9 ~: l/ ^3 l( {5 }4 d% T
- }
/ h3 u7 Z. c0 M8 }$ M - }
复制代码 |
|