|
|
* F/ ^' W* A, z" f2 |行,这个怎么样7 o8 P1 T& Q' N
- package com.xhg78999.mtrfac.render;
- \' E) j# ~% j% Y# Q/ B - 5 ?8 y, j8 A6 C% f( b7 ^. n
- import com.mojang.blaze3d.vertex.PoseStack;
& x0 [3 q% |1 r( p. {% l; a$ @ - import com.mojang.blaze3d.vertex.VertexConsumer;
$ V, z3 P% r% K3 s: D% D& n2 r - import net.minecraft.client.renderer.RenderType;8 j i+ p: h! n+ I
- import net.minecraft.resources.ResourceLocation;
( h6 p$ Z9 L, r3 E$ l) f - , C+ H( B( L q- y
- import java.util.*;; h) N3 F5 T0 f1 J
) r) C5 O2 m! \0 Q9 S- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(2 d7 m/ ^ g3 b- q" k3 q5 a
6 D( Z/ g. {4 B! E- public class LineRender{. c* y6 ~+ l" e" _% L
- private final PoseStack pose;
: V( q% G; p0 E' W& e! t( B( A - private final MultiBufferSource source;
0 F, `1 z* y, [8 D1 O - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
/ O, P& T6 t: i - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
. z2 l" |/ O7 Y6 |! w# {6 h - % ~& d) Z5 m4 ~& H
- : @' }/ J( t3 ?$ r$ N
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){. e/ C2 e" j ^* B9 Q: ^- G
- if(x1 == x2 && y1 == y2 && z1 == z2){
( _6 k- Y, U( r2 Z& {# t/ b4 ` - return;
* ~, ~; q: x& I& a - }. h; r H+ v- T" j
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){5 _$ {$ j4 R* P) V9 K
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
4 C( z# K( u4 v- J0 w$ W$ X% r - }
% k( @* X0 m) Y# c Q$ N - pose.pushPose(); @- K9 `9 f) t% a5 h5 j
- final int newLight = convertLight(6);; @3 G' Z" A% i0 t
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));' Q" W. c4 a p9 G/ D' H7 l
- final float lineHeightSmall = (y2 - y1);( z& ^, Z6 j' N
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
5 Q& k1 @. a1 s1 I# P - pose.popPose();
7 W; [, O1 f5 m4 v4 o+ i0 ]" k - }6 M9 O+ F O3 w5 S1 V( }
& ^" L& \* H4 J% h- private RenderType getLayers(String texture, int light) {2 u% C; s% H9 o) P
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));! ], x. b% Q9 I; V- f
- }
" S3 m1 n: G& I+ z9 B
0 P4 F P+ ^. K* ?4 p/ d, @! r- private RenderType getLightTexture(ResourceLocation texture) {
/ W1 q+ o0 a1 }% F# T# E - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
. h8 ]& f' R+ W - }
( z8 J: r. }1 K# t
3 u2 I8 j' L" X5 Z" I) g1 F- a- private RenderType getTexture(ResourceLocation texture) {1 K) u2 B$ l d) R" {4 ?
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
4 a, ]/ s; {% F$ _- Q - }
9 I; N# ^" O1 ~5 a% i" I% k - ) g! B; C/ `2 w+ U7 w" }! y) {$ x
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
8 Z, N# g) T8 `: K# z } - if (cache.containsKey(identifier)) {
! g* x' A- ^# O# V9 f- h- K7 ~ - return cache.get(identifier);
3 c& R9 N& c* H, {3 l; G - } else {3 b1 t- J" K8 Y
- final RenderType renderLayer = supplier.get();
7 u! Z' _2 ?- E4 Q) I" D ^ - cache.put(identifier, renderLayer);+ D; M0 Y4 i$ a# ?* D+ Z" A; Q0 t
- return renderLayer;
: n0 Z' t' v' m8 n - }
3 G5 S Q: y( [" G - }
* C; Y, g" r8 B0 i3 `+ K+ w - }
复制代码 |
|