|
|
% j( K* e% Q6 B8 X5 o( b
行,这个怎么样
& M8 O1 V/ v! I! D- package com.xhg78999.mtrfac.render;
9 v% I0 z# j- I, G3 _% U; W
+ l0 q. B' P2 Y+ o. B0 \* I6 U- import com.mojang.blaze3d.vertex.PoseStack;" Z% K; c* V) A; r5 I; |
- import com.mojang.blaze3d.vertex.VertexConsumer;
: z) k6 T6 m! v; f - import net.minecraft.client.renderer.RenderType;3 E) s! m2 B, p* X$ w7 K* i' k+ b
- import net.minecraft.resources.ResourceLocation;8 j+ N& `: Y! S5 K5 q
4 \$ A* g% i2 g) [3 F3 X- import java.util.*;9 y8 l5 h5 {; b( `
- ) y0 a' B8 D/ L* M L$ Q
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(/ c5 t( D8 M2 w4 ^. m% `
- 1 g% o5 g' [* p, t! H4 Y7 A4 F, Z
- public class LineRender{
8 u6 `# }9 v5 s: A U9 ?3 | - private final PoseStack pose;
8 x7 ^1 L6 p; Z5 { }" a8 h - private final MultiBufferSource source;
( O. V2 G0 \ S! n' {' X8 q2 L - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
d" U/ b' s; ^0 L. n" m1 [( W - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>(); r* r+ Z) ~: v" X/ p
- $ j i8 s# b! M1 O. D
- : F/ l( e+ t& F# x7 M6 w0 n
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
$ N' T- a5 j% k; y' r% d8 I# [ - if(x1 == x2 && y1 == y2 && z1 == z2){
" k# W) e% O4 K+ D5 t% E2 o - return;6 l( q- P/ B0 n; p# z
- }
_0 x. `) n$ m; E - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){! H* C* [3 e7 G2 _% Y* C
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
- ~+ f& o3 S& I3 w& D) _ - }
: s" M1 j: i8 Q3 ?1 R' H* A& a. e - pose.pushPose();4 @( I# y4 p& {9 H
- final int newLight = convertLight(6);- z( [& y- j. z
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
( Q" t8 Q6 g& z' ?" e+ ~- { - final float lineHeightSmall = (y2 - y1);
+ \) G0 w! x h& A# { - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
* C3 n" X! j# W4 F1 q - pose.popPose();
% L% h5 O6 N @ - }
# [# w0 u$ v$ m% w3 P b8 d8 I
- o5 T, F1 Z# Q! S; Y. Q- q- private RenderType getLayers(String texture, int light) {/ F0 {$ u. L+ {6 B4 I" _, s0 e0 q
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
7 \4 E% T5 Z0 `" W- J r1 Y0 F0 ~ - }0 @+ X; j$ c) W9 k) g9 Z& ~
- " r) F' \ a# \# f
- private RenderType getLightTexture(ResourceLocation texture) {' \! Y# r a7 p# [, ~
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);0 z/ m' A: S6 v8 L5 l2 y
- }6 r+ s: T. G1 Z; K; h' {
: t; n. O# H4 V# s$ a8 h9 c- private RenderType getTexture(ResourceLocation texture) {' z7 H2 K) o% q
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);. A- g, I8 U0 n& k1 ?1 @0 k' C
- }; N7 F1 N7 g/ A! v1 f
- ( r+ @, {! \" F
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
# r- _3 @. @0 G% L! U% j - if (cache.containsKey(identifier)) {
; h/ J6 I' H! N4 h - return cache.get(identifier);5 S. k& ^2 e: |0 Y# G2 y
- } else {; N9 z8 c* b" `- \ }1 I
- final RenderType renderLayer = supplier.get();
' Z+ z3 _7 R* V, {& m7 i7 F* O - cache.put(identifier, renderLayer);( I7 J0 g7 }' h2 P
- return renderLayer;1 `" t I* Z" u% P n+ P3 y- b* W. S
- }' c: ?7 c$ i# e/ n, U
- }0 w! }* D2 c$ i9 m) ^' y$ g2 S# D! v
- }
复制代码 |
|