|
|
# x O" a9 _+ v/ v! a! x
行,这个怎么样
V/ o9 O% K$ G- package com.xhg78999.mtrfac.render;
! l$ t; d, H% X6 C - " ? A2 _1 ?# q4 D9 q
- import com.mojang.blaze3d.vertex.PoseStack;
( L% k0 ^' r/ _- K - import com.mojang.blaze3d.vertex.VertexConsumer;
" g: D4 R( `& I5 P4 I: O - import net.minecraft.client.renderer.RenderType;
/ R# f, p, G) e; {1 K+ d6 V - import net.minecraft.resources.ResourceLocation;: R) A* l# @3 j: V$ H" X0 T* q+ M2 c
- / C* k% G% {0 n* [! O' m
- import java.util.*;+ h9 ~8 a! q6 e& O) o
5 o6 B# @; P, R# v: e3 X6 D* U# b" X- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(- i5 h/ ^# ^$ X( e% S/ ~
- : E+ G, A1 v& d T& R
- public class LineRender{6 t K, {* ^, p3 Y/ x
- private final PoseStack pose;3 h) `- j% w: L
- private final MultiBufferSource source;, m: M g: S) X6 C
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();, Y) x" ?% i% K
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
" R0 Q7 ^* b6 `) R( {9 ^4 ]/ `
/ z, S9 x5 d7 j2 O
6 @4 ?4 L# n! i9 a2 L- i, e- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){" @/ W; N" S& W+ Z% X0 h
- if(x1 == x2 && y1 == y2 && z1 == z2){0 C+ @6 s ^' E' e+ v! L
- return;8 w8 X9 U8 [+ @ \* F- f
- }
6 k! P4 K: o8 ?! s# N" U) X - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){8 a+ G$ o4 [8 U2 Q5 Y3 i
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
! R( r; j6 e+ n$ k% P - }
$ f' q, |1 v& A* x - pose.pushPose();" _1 F! b6 ]4 _" g; s
- final int newLight = convertLight(6);8 o9 { Q3 X' |8 N% t
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
; K a g8 q8 d6 t6 k - final float lineHeightSmall = (y2 - y1);- A) `7 B( o, j9 Y; M4 }% k
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
- U0 t, W" A6 n/ e - pose.popPose();2 n M7 L, b8 \* x" {) o2 f& v8 r
- }
; c4 [* D' l9 K% R2 T - - C3 Y9 y& z* N
- private RenderType getLayers(String texture, int light) {6 b: H6 S* i* ^8 r: m/ R
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));- t; t! f5 q) |
- }9 g; v1 m8 g v
4 m$ s) r9 P: `4 A9 O# X9 `- private RenderType getLightTexture(ResourceLocation texture) {
. u2 c1 d4 ]* ` y' U5 q' ^$ X - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);% _. e, X @- f9 a& `. u: |
- }% D2 t. j2 L6 R/ M* N- ?
- " @- g* ?- g( \( u P. c3 D
- private RenderType getTexture(ResourceLocation texture) { x; l5 b# [/ a6 z/ ^4 l$ q
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
" o/ l Z! O9 { - }* r/ N3 g+ y/ u2 Z% y
: M0 M' ]' U# [! L" u- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {1 o4 n0 w: n& c' v, M: a: w
- if (cache.containsKey(identifier)) {# c& n1 n0 t0 k! ~
- return cache.get(identifier);5 {; X1 I6 l$ ]1 l/ u" G" Y2 o
- } else {
) k3 g$ A+ |+ G - final RenderType renderLayer = supplier.get();0 ^2 ?! m9 Q0 {. _5 B8 @, n
- cache.put(identifier, renderLayer);) F% S- W3 i/ H& Q4 h
- return renderLayer;
! x+ C. v/ R+ _6 S- L9 M - }1 I" |0 |4 C0 J. v2 R* G
- }3 s% f; d% I6 H1 X |
- }
复制代码 |
|