|
|
8 ~/ l" k6 V( D! S; u( r行,这个怎么样; Y" ]$ N: h4 w$ q0 j
- package com.xhg78999.mtrfac.render;# n9 ?$ d* p8 T7 V+ }4 G/ Q, b
/ m" ^0 R8 r. X5 d- import com.mojang.blaze3d.vertex.PoseStack;
) s+ g! R2 C, r. F - import com.mojang.blaze3d.vertex.VertexConsumer;
( Q- Z8 y# u- [8 h; N" \ - import net.minecraft.client.renderer.RenderType;
6 C3 h4 y& W/ h+ T# [ - import net.minecraft.resources.ResourceLocation;
& j5 n7 T) K; _% Q& p6 s6 X
C2 [4 v- ~2 l T- L) V8 j- ~- import java.util.*;
& R8 p# s f' c3 z: y- D/ e - 2 H. F, \ L3 g6 f% \
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :($ u/ p+ `% D. H2 R& j+ p8 p
- " ^6 N {4 |, @' t
- public class LineRender{/ F. G5 ?4 D+ j) V. u
- private final PoseStack pose;2 D% [+ n; i2 m
- private final MultiBufferSource source;4 p. C, B) s# w7 v$ ], M
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
! `3 P* f: G2 J- h. A - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();5 @7 [. P9 D C( l: b
- 4 K' ?9 `6 m" B
! {* B8 T4 z/ Q- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
1 z) b( ~$ g. X2 O) X) [, q' W5 f, k - if(x1 == x2 && y1 == y2 && z1 == z2){" l5 L1 X8 o/ S5 q. p% M- p
- return;# a' k7 H) y6 H6 }5 R+ w0 S$ j5 t
- }
9 a; ]' H$ d% q1 k - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
2 l/ C+ n: i* q& ?$ d! s - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");' T2 r. X0 Y0 d% N: C7 O. ~
- }
1 I$ ~" i7 p8 G9 m+ K. t. z - pose.pushPose();: D% r7 f9 w; Y6 e+ X. E
- final int newLight = convertLight(6);: f! S8 H6 T9 A; R; ^9 \
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));. m" ~+ B1 b& n* x
- final float lineHeightSmall = (y2 - y1);, @: W9 p! k: R+ \, k
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);& Y& u( V8 O/ P+ S7 E% d
- pose.popPose();$ m9 e% R$ h: U( \ M+ ?; r6 z
- }
! r8 p9 J* T7 w
% X$ m9 u0 f# m3 u9 x, k- private RenderType getLayers(String texture, int light) {
+ {/ Y9 G$ |2 t* n - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));) h5 ~: j2 j' s% W2 v& [
- }
3 X" v5 T* b) c9 _) d* g# @
6 V3 @' Q& Q$ W) I, O- private RenderType getLightTexture(ResourceLocation texture) {
+ ?, F/ c) Y( |3 R; g - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
1 S' ?3 p! t5 {# F - }
+ D/ e' Y3 R0 S8 A$ G% f( D - 6 A- }8 Z5 \* B# B7 F
- private RenderType getTexture(ResourceLocation texture) {5 L5 N7 Q1 J1 Q
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
- O& U7 v- F& M1 g! p4 C+ v6 L7 S - }
* s- V$ a9 l# l
1 u- L8 u) c8 ^/ N- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {" x" r3 B( t7 z; [& q" m f
- if (cache.containsKey(identifier)) {
1 m" q7 o. R, I J$ B6 e - return cache.get(identifier); F7 E! T9 H+ o7 X
- } else {
6 t: H: Y& W+ o$ z% I - final RenderType renderLayer = supplier.get();* K, ^) P2 `6 i" ^& z$ _! Y
- cache.put(identifier, renderLayer);) v5 n* j# L/ G$ ~2 G0 L
- return renderLayer;
% Z* F! s) U6 i& k _; _; p - }
" d/ i D1 B% d7 K - }( F) B& U7 I1 S; T) M
- }
复制代码 |
|