|
|
+ M0 t! v! S4 I$ e- C+ P6 O; p
行,这个怎么样
~4 G9 C- l8 n9 @( Z- package com.xhg78999.mtrfac.render;* S7 v) s0 J. f! d
, I8 D0 ]* t" @$ K; Y- import com.mojang.blaze3d.vertex.PoseStack;" k% q) ^7 F% \) h
- import com.mojang.blaze3d.vertex.VertexConsumer;/ w8 V2 C. T& T' @4 J' i0 y
- import net.minecraft.client.renderer.RenderType;7 _5 h+ \2 D: n/ f, ~
- import net.minecraft.resources.ResourceLocation;# ]! p; m7 h- D/ N E! a1 a1 Z
z; z1 I3 M8 O0 d3 }" O: K- import java.util.*;; W r; V R, z+ _& b% x: L
- 9 `1 v5 l/ L- z# O2 x% n# U
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(4 i- Q# F0 K! a$ W5 d4 C
3 P5 [% i7 ], T0 ~8 j- public class LineRender{
% I$ _4 Q- Y+ |4 ^3 g0 g - private final PoseStack pose;8 s k( v# ~, J6 X2 k0 S, w
- private final MultiBufferSource source;3 J5 r% m( g# ]
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
- U* f5 B( R4 i E - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();( P* ]' h" W8 i
- 9 J8 Q3 v* n/ O
% \5 n5 j3 X* P5 T: L& P/ F- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){) v# `, g& a' w( m5 i7 T
- if(x1 == x2 && y1 == y2 && z1 == z2){
6 M2 J1 v& {9 K$ H7 ]* y - return;# Z5 n4 k6 {8 z6 u
- }
4 r0 O# k4 X! D - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
+ ]' |5 t& z' E* {- C" X - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");$ e" H) v; z- W3 s( d8 Z
- }
( E' w' ]* ^. O6 y: K# B3 S/ P - pose.pushPose();* p. [$ B6 ^; E+ x* C9 c( A% I
- final int newLight = convertLight(6);
! _0 k0 V$ w1 d, {. F. h4 H - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
" g3 R; e' f) q+ L; Y - final float lineHeightSmall = (y2 - y1);
, T/ ]9 }) c& W) R9 o - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
4 W& U; Q8 L& l4 N0 Q9 V# r& _ - pose.popPose();; G2 s; c3 L0 F
- }4 ]9 G# Y7 }( F
! m# n6 k% I6 j m1 T- private RenderType getLayers(String texture, int light) {+ M; ~) f5 h/ R( I3 x
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));8 `5 O" F# K) r% c3 M5 ?
- }
# `& ]0 P2 t% w, F. k) |8 D } B - / i( x0 {! L, l
- private RenderType getLightTexture(ResourceLocation texture) {2 a& [1 K% p! c8 [9 c
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
; ]$ [1 m+ U" J* o1 I - }
4 w! M% g" n8 r8 W- u1 c
+ T3 K8 V* }6 ]# q$ n7 W- private RenderType getTexture(ResourceLocation texture) {+ }+ s7 |* h) G- t# K! i
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);* c7 Q; \2 ?7 }. D9 C) s
- }4 A2 d- x1 L, Q- N
5 y* R1 Z0 [4 t. z7 |, H( @ v8 k% r- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {2 a! b4 @+ O$ Q. N( m
- if (cache.containsKey(identifier)) {
6 P8 r( J1 [4 m3 z - return cache.get(identifier);
2 w7 c7 p2 x0 e; W6 D/ }+ J - } else {& V2 @* j- C: y* Z y4 s1 @
- final RenderType renderLayer = supplier.get();
0 v' j) f v* o: x - cache.put(identifier, renderLayer);
- Q( z5 Z- Z8 r; c0 i, i - return renderLayer;
0 a. a4 t, E, n - }6 {5 I( C- I6 i* T8 y
- }
" R' ]# b3 I* L8 J) q2 s - }
复制代码 |
|