|
|
6 e' B- s: {/ ~6 C行,这个怎么样1 P. o5 u2 H, J2 i
- package com.xhg78999.mtrfac.render;- T) \/ p% y6 _/ ~. o( Y1 d3 Y
& {# B1 E/ x0 e% j t+ i/ J- import com.mojang.blaze3d.vertex.PoseStack;
9 g# n) u. u4 W, V7 P# K1 ` - import com.mojang.blaze3d.vertex.VertexConsumer;, c- f7 {9 q( y
- import net.minecraft.client.renderer.RenderType;3 b0 n5 {) {; K! r5 a6 X% d
- import net.minecraft.resources.ResourceLocation;
, s: y7 m L6 c
8 K/ @( N: Z5 z% x( o3 G# a# f. ]- import java.util.*;+ x% @6 e% I* o$ [
) X4 I- J/ v+ k1 A8 K" {- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(' c2 h5 ]& W4 `
% e7 p$ t9 u# Y- public class LineRender{
: c2 h, C' l9 q - private final PoseStack pose;; K) w$ I G P" |. V& f ]) c3 P
- private final MultiBufferSource source;
: Z5 T" B( w/ ?- q! r) h - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
" g! S/ y3 B! j5 G+ t) W5 } - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();0 z5 I$ n/ R, C/ |( Z/ z' C% X
- 6 L4 N' I5 |$ e
- C$ T: v3 V7 u* }$ V' o9 j: Q
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
. a. q; |: h' Z$ U- P2 P, V6 i0 u - if(x1 == x2 && y1 == y2 && z1 == z2){- N- r+ ~7 r. L N3 V
- return;5 m; P/ ?2 s n! }, w
- }7 ]3 A/ L$ c+ A: e( A
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){3 E) z1 N2 d) t1 v [
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
; D2 J) f4 L3 `4 T( ^2 S/ i - }
- f4 K$ G, S& U) G! A& m5 _ - pose.pushPose();
' y8 E ^7 B# I( ~1 U0 e- R - final int newLight = convertLight(6);2 y$ ^ b" T* r4 d
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
9 s: D3 J2 ]/ i j- V' O5 N - final float lineHeightSmall = (y2 - y1);
6 N6 q& P' }+ m! J1 t+ \ - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);1 {1 e: D5 ]5 R$ O
- pose.popPose();0 b3 y/ V. y# L/ s4 x; i1 I
- }
. i3 c- @" @# H: i2 x# p- z. ]' T% { - , e6 k, J) Q, n1 r
- private RenderType getLayers(String texture, int light) {
8 M0 U* e9 X) _9 ] - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));( _) o: f$ B7 \4 u
- }
k4 M# A, {0 ]$ o8 g
! |6 u& |# c) m6 H! s7 s$ ?- private RenderType getLightTexture(ResourceLocation texture) {0 I" I( z% e5 U! p/ Q4 b
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);2 A! W7 X E: n( ~7 h& b& U" d
- }1 a, F$ `7 P9 Q7 |. N5 d( X. w
- 4 k5 O4 I2 _# d. V
- private RenderType getTexture(ResourceLocation texture) {, H$ D: H4 h1 ]6 Z! C2 B. i" z
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);; N" _% |: S7 r! w- Z1 p
- }
6 B( J+ D6 f+ }6 D
5 \0 r' R l# H8 W. H7 ?- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
o1 B M6 q: j! c: M; C. Q) ^ - if (cache.containsKey(identifier)) {
8 D% u. P2 Q% ^- ^ - return cache.get(identifier);
: m4 x, \, G, o - } else {
- \/ Z+ U: Y& y - final RenderType renderLayer = supplier.get(); h2 N; ~; x- T5 V# r
- cache.put(identifier, renderLayer);
* a6 L1 q, w2 ]* _" v6 r - return renderLayer;" S* T. u/ X+ W% K' j8 i$ x+ K
- }
5 }' k" w0 \, o. [! K! I - }3 ^7 h8 j) n9 q9 |' U# z
- }
复制代码 |
|