|
|
# c) H! z, Y. L1 k
行,这个怎么样
) _ j+ v1 V' [' c9 p/ I4 A- package com.xhg78999.mtrfac.render;/ L0 l3 h g$ F& P W
" J4 w2 `3 t( u% D' x- import com.mojang.blaze3d.vertex.PoseStack;
/ e( t: M- D/ L% x - import com.mojang.blaze3d.vertex.VertexConsumer;
, V$ t" b& x |) X9 ^ - import net.minecraft.client.renderer.RenderType;
. I! Z$ ?. t5 K5 o - import net.minecraft.resources.ResourceLocation;0 t9 m1 S- b2 ~7 u
- - {0 w( q6 \ { L- J) {7 M8 @
- import java.util.*;/ p) \0 M; V* g z& n
/ f I5 f3 Q: g$ Q3 f2 A- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(7 W/ a( e. Y0 b. n
. }, h1 G# T! b6 \- public class LineRender{ `2 P3 n+ n( c# x
- private final PoseStack pose;
5 O I: d+ n; `5 }9 z, h - private final MultiBufferSource source;. k" y+ {9 z2 A6 v4 {( p/ L% W
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
1 ~3 p' x4 R8 _- u t& o5 f - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();% ^" w5 Y8 [2 w: h
- ( }/ j% M2 r/ A- k# d4 A& F; B u+ T
, ~. z7 i8 I1 v' ^& d- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
7 O {" r* y! W0 ]( |, C - if(x1 == x2 && y1 == y2 && z1 == z2){0 r+ `, V+ y3 M& J0 F
- return;
4 i! @+ Y. m! Y% H9 M$ N - }/ i& l8 C$ u. B& o k5 l
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
. g8 C, t# a$ m: a7 [* ?9 @9 E! ^ - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");! h" M4 \) e5 {% x
- }
2 [' u) L* L- N - pose.pushPose(); ^* K1 o+ [; u; v! e/ k4 ]
- final int newLight = convertLight(6);
& L8 ^) S4 p! v' {8 S3 r$ ? - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));% c# a+ u! \& j' n, }# o
- final float lineHeightSmall = (y2 - y1);5 _1 e% G" Y% L7 Q! ]9 Y5 K
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
' L6 c$ |& d& b1 X. a9 o7 i4 T - pose.popPose();
2 u- L6 l; j+ n; q - }) J; b5 _, z! u8 O: p3 \
( A; T% v' }/ E4 p- private RenderType getLayers(String texture, int light) {
3 `, E' j( |% @- e - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
! `1 \% m2 v) \ - }; p, H. x% e4 Z U% c
- % P, |8 K' R( c
- private RenderType getLightTexture(ResourceLocation texture) {# g- l( A1 [) w3 V
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
- k8 p7 }; w' \) {5 A8 b - }- K+ r' V' i- p7 ]5 \4 w& O# m; A
- ] H! H+ o" P% i
- private RenderType getTexture(ResourceLocation texture) {+ h4 C( w0 l1 _0 S8 A
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
' k8 O' f) t5 V! j$ B) C/ m - }
1 b5 A% }4 a. D/ N2 y$ O9 H1 P8 o
* _) D* i5 l5 A$ W$ s6 N5 x- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {2 G+ O0 z) ~. j
- if (cache.containsKey(identifier)) {
+ C, ~) [+ K1 f9 o( ?* o. P - return cache.get(identifier);
* Z U' [) \" z5 u5 R - } else {( J: ]' X+ @) O6 m7 A4 q ]1 m- }# G
- final RenderType renderLayer = supplier.get();
% p) b% q9 P+ t3 |4 k - cache.put(identifier, renderLayer);
3 r, i j W8 m- J& \, ?. e7 S - return renderLayer;
( a% Q7 r i# m' ~3 Q - }/ t R( }; d7 M: q7 Z
- }
/ ^- V" \4 w# ?6 N - }
复制代码 |
|