|
|
) b. q! S% @1 R4 Y/ x1 Y+ w) n0 t行,这个怎么样
' P& Y. P9 C9 ~5 w- w1 i8 ~, k, W- package com.xhg78999.mtrfac.render;3 D- k( ^, F, ? l" n
3 c( H& L: w- {- import com.mojang.blaze3d.vertex.PoseStack;
5 v- p9 J' Z; G2 j" u - import com.mojang.blaze3d.vertex.VertexConsumer;3 f( w4 k) {/ \& l* z2 f
- import net.minecraft.client.renderer.RenderType;
% G- F% q) i4 A( \/ d - import net.minecraft.resources.ResourceLocation;0 w, Q( O# k# a1 Q, w ^
2 B- J/ r0 U* M' n% \) {) G5 i- import java.util.*;
+ \! ~1 T! d: I/ L4 b) h& {5 |( K - / M' F8 I. M2 f
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(" g& c# A# F. j( ~4 Z; `
- . o8 k, ~) H5 r. |, b
- public class LineRender{
* K; J6 `/ M! j# B% K# g9 Q$ [ - private final PoseStack pose;
9 J& ^. M# ? R+ A2 c) O& b2 Q - private final MultiBufferSource source;
. v- z) }3 x7 D' T# e - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
7 j" j% S5 ^/ Z% S* O* Y2 X' u - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();! g6 \8 J8 v* y
- $ \! \5 A! j) U5 P* L
- ( ^ \9 P' c. x& \
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
+ o: }; J- q" d9 G6 U* [! N - if(x1 == x2 && y1 == y2 && z1 == z2){* _* c2 n0 D* n- Y$ d' J2 W
- return;% h/ l Z7 W8 L$ b, h8 M. Q$ @* R6 H
- }% `- _+ g0 ^4 L
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){0 @( s# K X3 Q4 c- D
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");* `0 K1 C Z7 V7 b3 V
- }
5 S$ |* t7 n: |( N' p# R$ D$ K - pose.pushPose();
: G* d& y k5 o* I* W* H B4 j - final int newLight = convertLight(6);
6 Z% K( u/ s3 x Y - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));7 O t8 b& v+ ?5 ~. |* ~0 H/ d. R
- final float lineHeightSmall = (y2 - y1);9 S# Z2 Y1 N$ d. b7 O* ], j4 T
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);' d0 [; s% }* r* _
- pose.popPose();6 i5 L1 X6 ~; R* t
- }
1 T# O" ~) z2 G2 N9 k - ) N1 M1 Q$ V7 K8 T
- private RenderType getLayers(String texture, int light) {2 o) \& Z3 F9 t C% l( l
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));0 [# w1 g9 Z* P
- }
[9 S' V/ O. B- b9 o E3 L6 _
- {" y* S/ | `0 p, Y! p! F3 K- private RenderType getLightTexture(ResourceLocation texture) {+ M; W& y C' M c: _: c/ F
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
0 l- Z [, J1 I - }
; Y( v6 U# J5 ]) n! | - / U5 U' o+ u, ]6 P. f9 _9 C4 O
- private RenderType getTexture(ResourceLocation texture) {
4 R/ L& U o( B0 R* u - return this.cache(texture, () -> entityCutout(texture), CACHE_B);" ~& m- Z" Q8 s& m+ [& Z2 R5 Y
- }0 [- q& X: L4 ]
- ' O7 a% E0 d# B1 v" G" M
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {, d; C1 ^3 P2 e; V
- if (cache.containsKey(identifier)) {
* a0 a$ V+ b- m, \ - return cache.get(identifier);
0 ?# l. a1 c& o# W7 U - } else {; J, {& @6 L* W7 o0 D- o
- final RenderType renderLayer = supplier.get();
. @' r& I9 H2 k* H3 w: T7 Q, F - cache.put(identifier, renderLayer);
% ~; I N7 b+ R% q - return renderLayer;
2 l, h+ o* _" ]) ?% G7 ^* U3 n1 e - }" O1 v+ [5 N) @) o7 N) N
- }# t7 W- O5 p- W5 `
- }
复制代码 |
|