|
|
; ^$ e2 U9 g+ P4 Q8 C% b2 l4 o# F
行,这个怎么样) e$ p5 I3 u0 T7 q8 y, J
- package com.xhg78999.mtrfac.render;
4 f/ H: Y5 O+ J, ~- d0 I
: o: m+ d/ {& ` d; v- import com.mojang.blaze3d.vertex.PoseStack;
$ D" e: f7 T4 c6 p' Q- Z8 h - import com.mojang.blaze3d.vertex.VertexConsumer;) D, Y4 ]3 Z2 r
- import net.minecraft.client.renderer.RenderType;% [0 Q, k/ D" D5 y6 X
- import net.minecraft.resources.ResourceLocation;
/ ]0 |' K* G7 f8 ^; L - 1 K5 k/ ]' }* }
- import java.util.*;
6 `. x* N$ y0 u6 q. G/ m7 Z- i - 9 @$ \' E) Z2 r0 F3 u6 ~1 Y
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(; d0 W6 a& p C2 }
7 n' L' E# [4 ]4 E, @- q- Q- public class LineRender{
6 b' n( N3 w. J# P - private final PoseStack pose;
1 n) c. ^2 y% e* D5 s - private final MultiBufferSource source;
5 o1 W& X7 I4 }' g5 K - private static final Map<String, RenderType> CACHE_A = new HashMap<>(); W1 Q) C& ?" \1 g6 j
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();" ^7 M' p/ r0 O. L! } x
- 9 i) G8 z3 ]1 H# @% I
3 C; V( q& E! o4 ]- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){) |4 t' V1 d. T6 {
- if(x1 == x2 && y1 == y2 && z1 == z2){
7 i9 G- d4 e. ~. W3 T/ }2 U - return;
! f8 V3 ]: O+ F J9 `6 R - }
. q& X0 i# ~% J. g, c/ R - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
+ b1 f' Y/ o7 \% ^( l - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");& \9 o8 ?; ~" y- b# ^( k6 ^
- }
5 p" g2 ]' u: P1 j. S/ Y - pose.pushPose();
& v5 y6 v( h; d* _- C. @5 j. @ - final int newLight = convertLight(6);- L% P* P0 u6 s$ j' g! u
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));* I& u- |( u9 k5 M" V' v* C p, z
- final float lineHeightSmall = (y2 - y1);' }- [5 B/ c4 r5 [+ g4 L Y# `
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);' ~$ [8 e4 ]0 S- P- E4 {* X# `7 u
- pose.popPose();
, ~: e. ]2 B. F |0 m# l - }
4 F. A# D6 I7 ?% T# F6 W - : P& C' V9 W" H0 E$ A
- private RenderType getLayers(String texture, int light) {6 d! G4 W! m5 r0 ?- S. o2 O' p
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
& p. f' s& {) r+ H7 o4 w - }5 w+ W1 T/ _ F( @5 M
: i- A' j) c+ M' v( Z3 \- private RenderType getLightTexture(ResourceLocation texture) {: T1 _ [8 C( l& p+ R2 `
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
- ~8 }; T8 K( f E9 D - }) p! W! _4 ?6 M M
- : O; I( y+ g9 L4 J3 E# W* [
- private RenderType getTexture(ResourceLocation texture) {
! V, F7 D5 q+ H+ @$ c - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
" q+ X B2 J$ c" t - }4 V4 E: B- ?1 y& k8 K" H
- 8 e! N$ x% U9 f% }1 x
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
9 Q( c S8 m; ^+ H( T! p0 `0 D/ m/ { - if (cache.containsKey(identifier)) {' Z# Q) V+ E* s$ F( \( Q6 O
- return cache.get(identifier);
; U E/ F. E& D" ? }; g2 ~ - } else {
4 [9 v7 h$ V( G% _ - final RenderType renderLayer = supplier.get();! t0 Y- b, S0 O% }" O" T P
- cache.put(identifier, renderLayer);
$ n8 h0 o- W. v2 n! r" B5 j - return renderLayer;
$ o1 b9 R7 \( u& z3 L+ _$ W - }
- |5 e$ i9 a/ n4 s5 ~ - }
* ?: h: l+ N% L. n; S$ a, J - }
复制代码 |
|