|
|
0 O" x& b" \* Q6 ^* K行,这个怎么样
! e; _: q! e* j- z- package com.xhg78999.mtrfac.render; x% x1 ~' o% J
- ( B, o- L8 v$ I% x$ B- ]: i
- import com.mojang.blaze3d.vertex.PoseStack;) f* m, B' h! R- K2 P
- import com.mojang.blaze3d.vertex.VertexConsumer;
' F0 w( `$ u: A; I/ u6 ^ - import net.minecraft.client.renderer.RenderType;/ q$ _0 f2 b+ E' b' E( g; U
- import net.minecraft.resources.ResourceLocation;: J4 F* T, W5 B% Y4 N& z9 P+ N
- ) m2 ~4 ^) b5 C2 l8 o4 H# F; }
- import java.util.*;
8 R$ K) r1 x0 A& I% h
# X; B. h/ o7 i2 \8 e* p- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
1 O6 B' k2 V& f) N
/ M3 {$ W3 c" |- public class LineRender{
' z( K/ G9 E+ X o/ g% g - private final PoseStack pose;
& \% } j3 S' i0 v1 b' ? - private final MultiBufferSource source;
! e8 R- k; Z h' W - private static final Map<String, RenderType> CACHE_A = new HashMap<>();# W0 b$ ~6 R8 w1 p0 {. P- T
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
) s& S: y" g2 H8 C% T - ) B3 v6 Z) s$ |1 c1 A! g/ v: q
1 [8 G7 g: c) \7 `$ v- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){" O) E7 H& J, z ~* P% t" t- g! j7 A. H
- if(x1 == x2 && y1 == y2 && z1 == z2){ N9 @7 J9 R1 Q4 \ h
- return;# B! E0 T- V) J
- }) }" k- {' j9 p( }. V. {
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){; j9 I! c% U y
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");& C) P |( v2 h* w% s- i
- }
1 F) C0 s% Q \! P" U - pose.pushPose();
8 N5 ~, J# P# k - final int newLight = convertLight(6);% r" Q. ]. O; c4 ^
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));+ b0 P* Y* f/ J
- final float lineHeightSmall = (y2 - y1);
$ ?7 p5 A8 O9 k: ]. j - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
2 n: a/ }5 @+ x, V- J0 e/ y - pose.popPose();) F7 R# r3 C+ D) ]4 {
- }
; c2 m$ y" Y4 w p9 G% T - 9 D# P/ b- v* _1 j& M( r/ Y
- private RenderType getLayers(String texture, int light) {" p5 h' R2 W' z: H
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));" }* Q. d- F/ j" Y
- }2 L& J8 w+ P9 d# C; q! X
$ C# L* V" ?7 T8 X( q8 y- private RenderType getLightTexture(ResourceLocation texture) {
) x6 m, f) r/ Y# V4 I5 F) c& R - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);7 @& l) I3 r5 u2 S5 T8 C" J
- }
8 s6 p; W& m% ]( h# w
, \$ R; w6 f. }2 ]1 q- private RenderType getTexture(ResourceLocation texture) {" _" ]( E- x1 W8 v8 q) d& j
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
' g4 _3 l1 p7 P' E* U# ] - }
! R: I$ H4 K1 [) Y5 E - " K9 U& k! g. H# b
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
# E' R+ N. z3 C - if (cache.containsKey(identifier)) {
. j+ _1 n7 A+ P8 S# D) K - return cache.get(identifier);
! @2 u9 e/ G) d7 e7 t - } else {
% I4 x' ~( F/ o* S0 z - final RenderType renderLayer = supplier.get();
; L. ?+ C3 r3 u# n& c - cache.put(identifier, renderLayer);
2 y' g/ `2 d& b3 F ? - return renderLayer;
& s" h! r- P2 P M: X/ S% L- k - }6 ~2 P- X( s7 H' n2 T3 i4 @& |3 P
- }
& O8 K9 r) V8 J: A2 x - }
复制代码 |
|