|
|
8 g7 e2 x8 n% C3 l7 E行,这个怎么样4 B9 }' o4 D6 M; o
- package com.xhg78999.mtrfac.render;
- s: n3 q0 T1 t$ r0 c s
0 F/ O, e2 |6 ]. E5 m; u2 j6 q, d; [3 \/ l- import com.mojang.blaze3d.vertex.PoseStack;
$ s/ x. ^/ G b5 [ - import com.mojang.blaze3d.vertex.VertexConsumer;
/ C$ s6 w: P" U5 I - import net.minecraft.client.renderer.RenderType;
# [7 e3 b) `4 r5 ` - import net.minecraft.resources.ResourceLocation;+ S0 v: t# n; }9 I
- - [! M8 H4 {/ q) N, ^9 F
- import java.util.*;* z+ ]. a% n3 w, u
0 U6 U, i2 B7 k3 y, u- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(" X! @$ [: c( V
- ( k4 C* m$ u' W; j9 G& m
- public class LineRender{
; p& V* T) b5 A8 j; n# \+ [ - private final PoseStack pose;: G% {! v4 Q8 r; U% R
- private final MultiBufferSource source;
( ?8 N* x4 R9 G( ^! X - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
6 x- H* N, I2 ~3 x6 s% ] - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
5 {/ r ^3 r/ n6 J) L- r+ K - 1 `6 g' X5 B5 i: `, V
1 b$ s% e1 Z' x) ]/ L- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){. T5 k+ b! p* d! q2 ^
- if(x1 == x2 && y1 == y2 && z1 == z2){
6 X: V# `7 H( }* W - return;4 h3 d9 Y( Z5 b. ^
- }
" m7 d$ |& q# S - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
; ?1 a e& X' C - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");9 i2 @; V) y5 p3 J
- }
" d3 \( a: [9 z# [* W5 S7 _3 E - pose.pushPose();
1 A4 Y0 D8 ^0 Y; k0 H, O - final int newLight = convertLight(6);$ j) y7 _, o% X- s
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
4 }" @( r3 L$ P8 e* m7 c - final float lineHeightSmall = (y2 - y1);4 J7 E! ~( J4 ]/ [3 O$ b" ?
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
" v+ l7 j0 ?* R# h - pose.popPose();3 }0 Z0 Z0 L2 ~
- }* S, i+ [* m- U% D! i
( ^! L3 R5 x1 o% d, x& C" [- private RenderType getLayers(String texture, int light) {3 d+ ?& {' m2 }; U0 V1 u: r
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
+ S% Q5 Y' y3 T - }
% D: I" B. G0 L+ Z% p! Y - ; d, q/ E6 ^2 [, G9 e
- private RenderType getLightTexture(ResourceLocation texture) {& y) x( S9 Z% E5 H ~% l M
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
" m; V5 b1 e, V3 O/ U1 @0 s - }/ j( u+ @# b7 }7 u- E% K5 |
+ f; c: b3 k2 |; h6 |- private RenderType getTexture(ResourceLocation texture) {7 A7 w) L, v4 P
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
0 }2 R1 F; C4 z; l3 W. w - }. F% M6 e0 b& e4 f! X
5 [' T, q, ?2 L% W+ Z- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {: E, W) r3 ?2 ^& L
- if (cache.containsKey(identifier)) {
, @; {9 T/ g- { - return cache.get(identifier);( F; Q1 l; y1 F' Y( _7 s, V; L
- } else {) S6 n3 H& T2 v0 Q W
- final RenderType renderLayer = supplier.get();9 p5 `2 d3 g# J& P+ C8 {
- cache.put(identifier, renderLayer);
% X+ y K1 t; u) x0 E3 e - return renderLayer;
! m, ~! C8 L$ I - }/ a1 X% w1 k6 }) a: ` O
- }) h/ p) i6 l9 p, U' K9 V. P2 z
- }
复制代码 |
|