|
|
0 d: A: ]1 I( X; L行,这个怎么样- s$ G+ s6 { H% j( w, X4 S
- package com.xhg78999.mtrfac.render;; ^8 O3 D1 l9 p2 z4 H( g
- / j$ n4 W2 D. e
- import com.mojang.blaze3d.vertex.PoseStack;
; O! b* p& a' S* ?$ G& [5 C9 i) B6 ~ - import com.mojang.blaze3d.vertex.VertexConsumer;, T9 s$ ^* t7 L
- import net.minecraft.client.renderer.RenderType;
& ~/ H" u- f X! o - import net.minecraft.resources.ResourceLocation;
; S& W3 V: Y; i - % D( g& H* X0 F; w1 F+ i @
- import java.util.*;
- y7 s$ k3 `& Y- L9 R" D# V
# }5 r0 |& \* d6 K) y4 l9 R- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(4 _1 M1 b8 [/ l; {" f! j. {
" K! q/ l. y: r5 \- public class LineRender{. a3 S# `9 J" o% v3 \0 @. f' ?% n& V
- private final PoseStack pose;
; C$ ^# S* n; W0 B" {( H8 V" ]+ k - private final MultiBufferSource source;
) `( A: s) c' L+ q. p9 J - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
& S8 ^8 a7 q6 u+ s$ j' t - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();/ O! y. p* l: X4 P5 A1 }1 t
- + D- y% ], @ @) W/ ~2 s5 U& y
6 w7 ^* G: R0 J& D5 ]- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){5 X) W! \7 y) e9 _; r, _
- if(x1 == x2 && y1 == y2 && z1 == z2){- Y$ ^7 B) ~5 M4 G: `
- return;( s. r2 a) k& D; y5 I
- }
5 Y- {( `4 I4 d - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
* w) ]+ N. c! T5 M4 s& b. M9 L7 A3 } - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");; v% |. } A3 b, G
- }# W# ]1 I: x5 o, [2 P
- pose.pushPose();
# f+ Q' Q& d6 d5 r1 K - final int newLight = convertLight(6);
- |5 W' h+ V% u0 n7 f" \( H$ B - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
9 e& J/ C+ G$ r1 s' U - final float lineHeightSmall = (y2 - y1);
# M- m& D" @. s - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);) S5 B. o0 g2 o8 f1 _, F' A! t+ o9 F8 o4 U
- pose.popPose();3 E. f. z1 w( L* Q( _
- }' s1 I4 n& e% k. t4 y. A
! A& [; N' Z6 B8 ?/ d- private RenderType getLayers(String texture, int light) {
0 ?% H' I- r6 E! h - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
1 J: T/ O9 N. v4 q - }* b4 v' c+ w% H3 X) H; S; ^4 B$ }
; ?1 s+ n7 w) I6 |1 R0 u- private RenderType getLightTexture(ResourceLocation texture) {
; r) h/ O0 a/ v+ F. c1 s - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
: [; S3 C0 ~- R: K7 v( Z3 M - }
7 n. U3 f4 c8 B& O
2 u( H! ~5 _4 ]7 h$ e# Q- private RenderType getTexture(ResourceLocation texture) {
4 m0 ^/ H: |' P2 W. |0 W - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
- o2 Q. Y, B7 R6 A; U - }" r. R8 v: m8 c
S( B# F2 Z( ~7 ^. @/ ~' E- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
% @6 v+ c$ u* T$ G- e& i- T/ `. P - if (cache.containsKey(identifier)) {5 g& Y) ?' e C
- return cache.get(identifier);
7 P, z% W0 {. _8 j8 p) O' R9 D - } else {
# i9 F3 X; E# [$ l - final RenderType renderLayer = supplier.get();: o4 ?: m9 U+ t! R
- cache.put(identifier, renderLayer);$ C9 C4 e: C9 g" w3 h
- return renderLayer;9 S7 }8 {" j6 k0 _! C
- }5 W7 ~$ o2 O4 h1 _
- }
# w. F" W; y) w3 T - }
复制代码 |
|