|
|
V5 I) B* ^( l( N" `( Y行,这个怎么样
" t- J# M+ F5 {. H- package com.xhg78999.mtrfac.render;
5 T" s. @! m; ]: ?3 j - 2 f: O8 _6 {" v( P8 O2 }' d
- import com.mojang.blaze3d.vertex.PoseStack;( @9 U* L' ^# W( M
- import com.mojang.blaze3d.vertex.VertexConsumer;, u, }! z& Z8 q; G! \* i5 _0 p: S+ S
- import net.minecraft.client.renderer.RenderType;
, Q) ]$ O4 h9 l- |. r/ Y - import net.minecraft.resources.ResourceLocation; x2 r9 F8 p% Y% U; k
- 1 l$ z1 d3 _1 ]- F
- import java.util.*;1 n, k1 V) T P% l7 c
- 3 B& }3 U- m, n" o) {
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
7 h0 h# ?4 {, ` - 8 ?5 e, s$ k& e5 H7 T, L$ `
- public class LineRender{
; ?9 ~- C, h9 h. S" W - private final PoseStack pose;
0 a5 N2 B# v) w) R% I - private final MultiBufferSource source;
; v6 G0 L/ W6 O5 v x6 r - private static final Map<String, RenderType> CACHE_A = new HashMap<>();' e9 |# L! W2 f8 R: L) \0 y* ?- @( s. ?
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
$ O; a0 }8 }' i/ `; p% S - * c9 \/ w9 ]. c
@" G; G N8 w- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
/ ^ V5 r; F2 U- L7 K& X - if(x1 == x2 && y1 == y2 && z1 == z2){3 A; s8 W% m# t) V3 @3 C4 S& a
- return;/ i$ h5 _$ s9 r# X4 [
- }" d S- e8 W9 V. T! [% H* j
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
+ d( y% h3 c- i, L2 z! j# K8 P- k - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
& S1 k4 u7 D2 s) |" t+ \ - }* O6 u+ o. j) |) d, k
- pose.pushPose();, ~' U9 G* H8 F$ W' h
- final int newLight = convertLight(6);3 k" [+ M) G9 A% h& E0 }1 K
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));; Z* w4 F! o# I4 I
- final float lineHeightSmall = (y2 - y1);( W; b6 T5 g P |; q5 D! T' W Z
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);* j4 N$ H% N8 l3 t1 R0 m. L6 A, {# n
- pose.popPose();
/ Q9 k& B' e% b! K& B- \ - }* N( s/ G% F( |' _& b
- : Z# W, f$ Z. \" D% S5 |
- private RenderType getLayers(String texture, int light) {
) P4 C3 V5 u& b+ x - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
U% `0 D8 }: R$ i( D7 a/ y - }. G ]8 ?2 y0 v
- 0 S% |' W9 U7 q- B$ D( R5 }/ G
- private RenderType getLightTexture(ResourceLocation texture) {
) H9 u9 N9 o S" B$ U1 H6 n - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);" X; |0 \, A* F M0 ^, R7 q
- }
; a I/ r; U9 G, ?! i& \4 Y - 1 M# u" \# i. Q
- private RenderType getTexture(ResourceLocation texture) {7 N0 `/ F4 P' r% g( O: v* e
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);. E& a9 G7 s5 |9 Z! F/ @# g+ t% I
- }
! h: B' F/ e! R0 ?# P, K0 B2 u& p - ) S* v; {3 |* O8 i
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
; L7 B4 I- \0 M0 K/ L2 \4 D - if (cache.containsKey(identifier)) {
* k' I: F2 `! m# R1 M m - return cache.get(identifier);+ t3 Y3 l, }" L/ w4 H& R! E
- } else {
- T8 Y$ {+ _+ v1 ?# P2 Y - final RenderType renderLayer = supplier.get();
# W: ]* S* Z! C - cache.put(identifier, renderLayer);4 {: C. v; T8 y' j1 G
- return renderLayer;, r* y+ C. ?: K$ G0 J1 e
- } ~- b* h- N; G
- }/ h7 h4 o( i5 P( \+ g
- }
复制代码 |
|