|
|
' ` E8 d4 R& U$ B7 b0 e4 S行,这个怎么样
9 l* f2 u* m7 L E8 _) S2 }- package com.xhg78999.mtrfac.render;
- g3 V% z2 a: X2 c1 O4 @. D
- ^; x2 v3 Z9 k6 Z6 |+ e- import com.mojang.blaze3d.vertex.PoseStack;
, R1 | v6 G9 Q; n+ Q7 F) } - import com.mojang.blaze3d.vertex.VertexConsumer;& w6 X7 W0 U* z; W) r
- import net.minecraft.client.renderer.RenderType;& Q; Q- }6 |6 J6 n( ?3 J4 \+ G
- import net.minecraft.resources.ResourceLocation;
: Y8 H+ F a" ]4 m4 Z
8 Q1 o: @0 h% P" W- import java.util.*;. R' ?. Y* ]. K- S: x9 z
- ; ~ h: m/ e- G# a# T& B
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
% C$ x6 @. W! x6 U. S. E - , L' e. N# n8 l& I1 u! c6 v0 |
- public class LineRender{
- U* Y& ^/ u* P5 @1 l- m5 Y: z' ` - private final PoseStack pose;
3 T( g& [5 _. V2 } - private final MultiBufferSource source;
" g, Q$ a$ `; M. Y. [% L* _ - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
. x6 V2 y8 G N7 r - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
o7 `* H& n! y& `
9 K$ Q' V/ v# ~9 f. c
! V8 x. g4 ?$ A3 _* G$ R# ?5 a- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){4 D" [0 [ ?$ ]. U3 H9 }
- if(x1 == x2 && y1 == y2 && z1 == z2){4 [4 C7 M$ c4 B) d
- return;
; \+ W3 L- Q7 h - }: m* N z8 F. W2 J4 s
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){5 G2 V1 x$ ~7 V5 ]! H
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
- s4 p }+ q: w t6 U; ~2 Y1 y - }
" @, `( r6 c1 v R( t Z' Y4 ~ - pose.pushPose();9 t% V. U. @5 u9 P6 ~" s1 z. F
- final int newLight = convertLight(6);! ^; n, X6 {5 [6 u, W$ o
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
7 s" M1 T4 {% [" ~5 ] - final float lineHeightSmall = (y2 - y1);3 ^# ~1 `7 _; z% T& I. n5 W! m$ k
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
# T& E+ C9 \! L! x& y/ Q - pose.popPose();% \) a& Q) L# ^) h) i- o
- }- [3 @8 x( |+ d* f& l- j
- 7 }5 C0 Q, N4 M) I
- private RenderType getLayers(String texture, int light) {
: |9 ^' {: k" m* @) v6 h. u - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
+ R+ o( c+ q" \) z! l9 b - }+ i5 f3 G6 E# K/ D3 k- S
- 2 X" ~/ g7 _7 v8 t7 {
- private RenderType getLightTexture(ResourceLocation texture) {
~; W( o4 p2 I - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
% l+ g- E& E7 M% d3 p# J9 \0 M - }
7 }" g+ H3 k0 O7 t+ ?, D9 V - ; c! g$ h9 Q8 w: Y: Q
- private RenderType getTexture(ResourceLocation texture) {1 D7 |0 n9 U2 n1 G8 F9 |
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);9 g$ T6 w) O& O7 } r+ H
- }
9 E$ c2 }3 d7 B! M; m - 3 u0 h! ~9 B9 @4 \
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {, m2 \2 [3 U) M2 K: X
- if (cache.containsKey(identifier)) {8 [7 P. {$ y1 K j! A8 ]2 G
- return cache.get(identifier);. o' n2 V4 u8 }+ L* v# k( ~
- } else {
! G. D r8 a; S6 {! Z) P: ^ - final RenderType renderLayer = supplier.get();4 `; W8 {1 G% h
- cache.put(identifier, renderLayer);
. k r$ M6 o5 Q' g; A - return renderLayer;
- M$ K/ V& o) [- N7 { q - }$ U5 l1 q% y, t8 _* @
- }
* b4 O. H8 b& f* S( W - }
复制代码 |
|