|
|
( i; {( P: ~& ~! b
行,这个怎么样: \1 M5 D$ t- G' ?: Z) ^* v
- package com.xhg78999.mtrfac.render;7 o3 R7 I- M2 w2 v) K
- # l; y5 ?7 C2 R2 d$ |7 p
- import com.mojang.blaze3d.vertex.PoseStack;
9 _. U5 `" A2 d& L6 i1 v3 `9 ~4 E - import com.mojang.blaze3d.vertex.VertexConsumer;8 A) s8 t. w5 [
- import net.minecraft.client.renderer.RenderType;
`/ U7 j* c- F% q- G1 g - import net.minecraft.resources.ResourceLocation;* I5 @, e2 H# Z6 S# u3 X
- ( o; M, D* D; ^% D' k7 i; g
- import java.util.*;: s+ s% o! G `
- # m) ~$ t( [6 r) g( m) h8 Z
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(5 V# m3 x7 T9 I/ e- \
- : R# |0 }! L, n" t$ W
- public class LineRender{5 c1 S3 i) g0 n L; A
- private final PoseStack pose;0 J6 C5 Y1 u/ I/ m' N
- private final MultiBufferSource source;6 A: Z8 B7 r* Q+ D3 S9 J
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();- \1 D. I# _% Z) P
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
, N4 d% M. | `0 c1 j" z7 x - % z/ ?8 U# V1 @1 V
8 Q: U' b( `2 V$ @- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
3 F8 u1 W' Z+ u' I& H8 ` - if(x1 == x2 && y1 == y2 && z1 == z2){
+ E& Q' U. Y0 `+ P0 o) r+ t! e - return;) Z& ?. O; z$ m
- }0 d) {( o2 B0 k0 U4 l8 I
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
+ K6 \+ J |' G) X - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
# N: _7 o) r, e' p: p! ?+ I3 k; g - }
% W! u5 D1 V% Z: ] - pose.pushPose();5 V- S- \; t+ ?7 K
- final int newLight = convertLight(6); R. s5 V3 o6 c: _4 X" L7 g
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
: w6 K/ y4 y9 u: i" ] - final float lineHeightSmall = (y2 - y1);
/ g5 Y( j( _2 a0 w+ U4 C) f$ ^5 d2 E - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
4 ?6 u$ y8 M3 }1 p# _2 S f - pose.popPose();5 o. H6 r! K& I* S8 t: @
- }
% `4 V/ l7 v6 I0 Z9 N, y
: F* \1 Q! O. Z- _# B- private RenderType getLayers(String texture, int light) {. x6 I. T. @* s
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));: R$ S$ X7 L K3 H# c
- }& A2 o* F+ }, P) L2 z. X+ G! A
* y) x# p- k }' [- j0 x- private RenderType getLightTexture(ResourceLocation texture) {" y; {: z/ l# `% `$ a$ w
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);2 ~1 R2 M" v# I+ N4 l
- }: `0 H H6 A u- l' |1 Y
_5 p. Q+ Y# c( T2 k. y. F/ h- private RenderType getTexture(ResourceLocation texture) {1 G. a0 |" E- p) Y
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
+ o- o2 Y f, g; @) K" m. |+ B9 u. @, ^ - }
1 R* h2 d i t2 b* x3 P) x* I* D
5 c' }# y5 q: B, t- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {& P) S# H0 y: v9 A
- if (cache.containsKey(identifier)) {
$ b% W. h1 A. U - return cache.get(identifier);! Y" o0 }. V" Q0 [
- } else {
* ]: ^9 K& D Z$ _0 ] - final RenderType renderLayer = supplier.get();3 g1 ^5 U) E- D' Z% W2 X( k2 l
- cache.put(identifier, renderLayer);
: m \1 r: H; y S0 y1 [ - return renderLayer;
$ ^2 W) L- v, Q* b - }
2 U7 y8 x8 S) i6 I% r - }" V6 \8 O) I+ O8 h
- }
复制代码 |
|