|
|
6 t- @/ b; e t+ M$ V/ ]
行,这个怎么样
# T2 I6 X' G/ p p7 u- package com.xhg78999.mtrfac.render;
/ r7 r$ Q4 {1 [7 c4 P6 f1 X3 v
! c* S+ Y) Z1 l; A- import com.mojang.blaze3d.vertex.PoseStack;6 q. \6 t+ ~" h3 n
- import com.mojang.blaze3d.vertex.VertexConsumer;3 l9 h+ H% T( Z$ t! _; l3 @* |8 l/ @
- import net.minecraft.client.renderer.RenderType;, [/ A) p f" s2 D) H
- import net.minecraft.resources.ResourceLocation;( ] B8 u; S" w( c2 v, b$ Q6 p# i
- 8 c) C! L1 B" q
- import java.util.*;: Y e5 y* x, l) E1 N A# o
+ Y! N) u/ V9 N# k7 h/ c4 I8 l" j5 u% h- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(1 }8 V. V Y" f; F4 v2 _$ \
3 @, w& ?( F% f6 N- public class LineRender{
5 E: `& u. I, H - private final PoseStack pose;; f0 F3 A h7 B+ d
- private final MultiBufferSource source;- {8 _# t8 M8 v7 i
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();/ B2 e4 ^5 }7 r8 J8 f- H
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
7 ?" P. y' d+ @
# C' ^* M& d) g; ^& l2 ]
+ t4 j& H2 F3 m8 c/ ^- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
" f6 x5 E9 G1 ^5 i! n$ d4 } - if(x1 == x2 && y1 == y2 && z1 == z2){3 k" x1 i: T5 W
- return;
. }0 e, A# \; Q* R& E - }4 T' [) N) L) R, W5 h+ @
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){5 E9 \/ G9 M% r" L3 ~/ k
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
, e" ~% R% b; m$ G$ D0 ?1 | - }: s, S# h3 m3 u/ x0 Q5 c
- pose.pushPose();7 ^" d p7 |, _" J4 q! |4 U
- final int newLight = convertLight(6);3 x8 |3 _9 n& M, A
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));7 }# {8 E8 _9 f* P) n
- final float lineHeightSmall = (y2 - y1);4 i+ w( p2 }6 Q* T( B6 {6 a$ g, T5 v" j
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
+ b( I" w) a6 M1 C2 m* n$ O9 ` - pose.popPose();
# @" B; x6 {- Q: y" ? - }6 D1 H9 _" J( v! m2 m: j
+ `8 n/ l4 I( |5 y" Y9 i- private RenderType getLayers(String texture, int light) {! _5 U0 f: i: Z" g9 k u0 R
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));% f9 X5 {5 p$ s: s4 N; }7 A7 C2 V& ^
- }/ [4 X' [ }/ ?% U' v. t
- % V4 g# M, w! B5 ~- z: O: h# z
- private RenderType getLightTexture(ResourceLocation texture) {
* `8 n$ K9 m% a( I+ F$ @" W' Q - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
% o5 ^8 `1 p" i m - }
. g8 @( }" b& g8 [/ o+ _
/ U2 J. P$ Z" `7 t0 |- private RenderType getTexture(ResourceLocation texture) {
& N; D$ T/ G* R# ] - return this.cache(texture, () -> entityCutout(texture), CACHE_B);) }1 D0 ]* l. M {8 r; y; G
- }
|* b0 T b- ~$ u- y
5 V) ]# m% C- v- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {5 A) [4 _: c6 D
- if (cache.containsKey(identifier)) {
8 J7 n, _% e2 I# O - return cache.get(identifier);
# |. U! H, P" z - } else {
, W0 t( Z d: b9 i; H - final RenderType renderLayer = supplier.get();2 D' i+ \4 _+ M) |8 g- `
- cache.put(identifier, renderLayer);
$ r- M) L8 H# i& S8 O+ r- c; V; d - return renderLayer;
$ C& E4 i1 P0 f- j \' k3 Y1 o - }
2 p$ A3 m8 A G* K3 g7 Y/ v - }
- o* O7 O0 e" P# a$ `8 C - }
复制代码 |
|