|
|
; K( P. l9 d# P% r7 J5 ?
行,这个怎么样8 W9 s+ Y8 C2 b* K* {9 C' r: {" P) j
- package com.xhg78999.mtrfac.render;1 ]1 A; J! U, M, U
- % {$ x0 z& Z) x l' {% j8 m, m
- import com.mojang.blaze3d.vertex.PoseStack;; i) c4 r7 {8 S2 a* ]
- import com.mojang.blaze3d.vertex.VertexConsumer;, y8 R( R% A" s2 ^ v
- import net.minecraft.client.renderer.RenderType;
. r8 e3 g! a6 \' E - import net.minecraft.resources.ResourceLocation;
6 a9 S) Y3 h2 M
+ x5 L. q% \/ `3 Q1 r- import java.util.*;
8 A, d1 x3 W: y& W& u7 ?* t - 1 n7 E) X9 Y4 e0 ~+ |3 D! X9 j
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :() `# R C/ x/ ]( Y9 M6 z6 r9 p
- & [! i [. m+ @( D. T: U* G
- public class LineRender{. i1 X6 B7 X% K2 Y$ X6 E$ U$ m$ Q; s
- private final PoseStack pose;
5 E2 F7 t+ a _8 @3 n2 n9 L3 q - private final MultiBufferSource source;
% ]2 v8 C5 X# p, X! D1 C - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
^ g7 s" p6 j* e R' R" S - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();3 z# A) ]* u# o6 b g3 p3 x9 i- G$ U; ]
9 k) x7 w5 G8 Y: n( r/ Q& V
$ d0 Q: F) `+ ~' Y& k! V: L! |- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
_1 C: ~; B( u! H( B1 ] - if(x1 == x2 && y1 == y2 && z1 == z2){
6 P0 h W: `7 I' ]) s - return;
9 j2 Y" z3 D, | - }3 o& `* P& l3 B. ?: f) |
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
0 n/ k, z5 n& F# d1 P - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
* }- g* A$ T! T0 h* u1 V! Q - }
) c3 D- Q8 @9 n% q' F; G - pose.pushPose();
* U; B9 _3 S& i# f5 s# L! l* ]/ \ - final int newLight = convertLight(6);! _/ U# v8 ]% m0 | B9 j
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));$ E, a: v; n& M1 I* U
- final float lineHeightSmall = (y2 - y1);4 }# u% ^1 v/ Z; Z. E
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
, |/ ~/ P4 |. M - pose.popPose();
3 R. k$ k- Y: k* m0 }/ q; \ - }0 y6 M8 ^0 v2 |7 d; b1 I& M
- ; s8 e6 I: Y0 y( \5 b* l6 T G
- private RenderType getLayers(String texture, int light) {
3 }8 ] v) R7 c - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));% j2 T, p- j' y3 P: I8 i2 l
- }$ Z: M+ X: ~5 Q% e F" I% K
- ) e% N. k9 C" ]$ z; \8 R# I
- private RenderType getLightTexture(ResourceLocation texture) {7 Q6 i* O5 ? Y2 {. i( d4 l
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);4 N6 g$ m! f4 g+ M% P6 d2 B2 T/ ?1 d
- }' N: [ Q4 p' f m0 T
- ) B/ p$ k5 R9 c& G. h# A
- private RenderType getTexture(ResourceLocation texture) {8 \9 r/ @" ]. M. W
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);- [: e4 T; _$ A. i8 B
- }
4 F0 Y3 _& w, c! m+ g$ n - " b/ {1 U( q6 G" T' G4 b, B
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
9 p7 M9 P! `( ^ - if (cache.containsKey(identifier)) {
! g0 _4 J* O. P$ B* v# y7 B - return cache.get(identifier);9 k) T( r+ G2 T0 Q# c( l
- } else {
: ~5 V, A9 _: j5 f4 t - final RenderType renderLayer = supplier.get();
; J. ]4 g; d& X$ g - cache.put(identifier, renderLayer);3 s7 z+ T/ V( {
- return renderLayer;
* }1 C/ L/ D$ ^5 p - }/ d0 ^. ~4 B% q9 y
- }3 ]( G# T s+ B- i! i
- }
复制代码 |
|