|
|
( R. R4 J: X( L8 Z( B" h3 Y
行,这个怎么样
9 O t8 c, O W- package com.xhg78999.mtrfac.render;9 V8 W/ P! w! p* k
- 6 ]4 o2 U; |0 p' x
- import com.mojang.blaze3d.vertex.PoseStack;2 x z/ c2 f6 ~& B+ L% a
- import com.mojang.blaze3d.vertex.VertexConsumer;* Q3 ~9 l4 |( G, Z% L
- import net.minecraft.client.renderer.RenderType;% i2 K( S, P5 f" L4 k
- import net.minecraft.resources.ResourceLocation;
9 o5 Y* ^" Y! V$ n) [* b3 d" _0 ~
( B5 b& J [7 ], u7 m5 K" r" P F" ~- import java.util.*;$ e. z$ e" S. a: A: i# o$ ~8 t$ b
9 O. A. o6 g' z# ?- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
H l% V% z- V, d4 v - 5 b: `" u8 a; E
- public class LineRender{3 M' a4 d2 h6 D+ g! r; h
- private final PoseStack pose;
' c) Y" @+ J3 Q5 c - private final MultiBufferSource source;0 ^) n/ S& O" |9 L4 x5 \& x0 m
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();; I, @( s0 [+ G
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
# _1 d1 n* n p6 ^/ i
! t' l! u, |) K3 ^& H; k
1 n) }) k5 \1 j9 ^, s, M; D- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
* L$ u S: D, V' R0 V' n- @5 o' m - if(x1 == x2 && y1 == y2 && z1 == z2){
/ ^( K( @0 A4 O, ^ ?* D/ E - return;. ]0 I- E, Y0 l5 A. _7 o4 [# @
- }" X8 ~; k+ J# \8 D
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){" N- W$ @+ d9 n% B w
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
+ k* O" L2 R0 U# f- { - }
: Z, W1 {) n$ Q1 |) i3 S! f. j - pose.pushPose();
; O4 y6 n8 R; n - final int newLight = convertLight(6);
, ]2 C* q4 j3 Y; i - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
( \; C* E B- c3 V& N v X7 h" G - final float lineHeightSmall = (y2 - y1);" d% b$ A1 D ^2 C/ v
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
6 m& E6 X+ z) U4 g - pose.popPose();& D- G) f& L* J! o8 e3 F
- }; T9 W* A8 E; E8 X3 U% m
0 q) ?& d) O# ~2 o6 S7 ?- private RenderType getLayers(String texture, int light) {
2 x. i" ?7 w, X. X9 d1 J - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));. h, E# z4 `' c3 Z0 {4 B$ V
- }
; q) o L4 b0 s$ } T6 K( D
" h% K* x. d: V+ l- private RenderType getLightTexture(ResourceLocation texture) {
% H' ?5 M) L9 `$ K( p - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
/ V* i& M2 n, U& O% ^# }- ] - }& c% o) L7 @! j$ o) f1 X
- 9 z* H+ V6 h/ K3 R1 }) Y
- private RenderType getTexture(ResourceLocation texture) {* P1 N2 B8 c* f
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);8 V. Z# ^, d% V
- }
$ x6 ^/ e7 y4 [; \1 B5 Q& q& I - 0 q' y/ f5 Z! Y5 R( B
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
/ q& z* k& n7 ~; F - if (cache.containsKey(identifier)) {
. [% C# J7 }" ~$ V3 W; [ - return cache.get(identifier);1 }8 I G" E4 H3 z
- } else {$ G$ S% M- b: Y, P
- final RenderType renderLayer = supplier.get();: t( T! ^8 l) e( v7 K0 r$ g
- cache.put(identifier, renderLayer);0 p" x. @+ J5 H7 h- l$ l1 Z8 c
- return renderLayer;
7 t& m3 }& x- {3 P/ J. y$ l" L3 ~ - }
( F* ~- N7 V6 w, @0 H - }/ ]4 Q9 m# N0 ?2 _; e& e+ q
- }
复制代码 |
|