|
|
! h6 K, q6 R/ h0 l+ J c
行,这个怎么样! E$ {+ M& b1 e# h9 B
- package com.xhg78999.mtrfac.render;4 B% u: @; Z4 e- O$ o
3 M$ h \* h0 ?' T" u- import com.mojang.blaze3d.vertex.PoseStack;
3 c+ d* O2 N7 P5 O' B, ]" `) Q- o$ } - import com.mojang.blaze3d.vertex.VertexConsumer;
- h/ x: u- C H% x0 a3 [$ } - import net.minecraft.client.renderer.RenderType;% L% ]" r. @! }* i4 B
- import net.minecraft.resources.ResourceLocation;
# G- N* l( ^7 O+ h0 {# d
+ ^* U2 Z8 }2 h: c9 `- import java.util.*;
/ Q3 a% |2 b- S: K
$ R2 j/ T/ n0 W3 e! ?0 z& X8 V- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(* G Z9 _9 h r8 x" {
- 8 [7 |/ Z% G$ g0 I. d5 n! \
- public class LineRender{
9 a n$ q& z; f* z5 c4 C. C - private final PoseStack pose;
# w5 b) {! e7 a: P; p5 { - private final MultiBufferSource source;) v \. ^) p6 C5 X0 e
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();3 R( d& m4 }. ]. `
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
$ f; Y7 o/ @* Z$ k9 {
9 c' [9 l8 I, q9 @
6 ]) m. t1 |& ]3 N- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
( n* b* b2 g0 e( q6 F: Z - if(x1 == x2 && y1 == y2 && z1 == z2){
; K" r( d( ]; c" m+ P% Z* W; a0 V - return;
) Y1 |5 r9 V6 [/ ] - }
5 z% b, U* d: g$ e& [. s! w - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){" L3 h/ i; e9 G' g; K# ?( a
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");4 i/ x z# { @# d9 E7 M4 r
- }
. r) W. ]# Q% N2 J# v0 ~ - pose.pushPose();" g: e8 |) I, L5 W
- final int newLight = convertLight(6);( W. o. H; Y# C8 s+ o5 P
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
4 W5 g* _& v! R E. u- x# N - final float lineHeightSmall = (y2 - y1);' S. x5 I @, n* B7 o6 [) }
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
2 a/ b* ~ y4 s K" ^ - pose.popPose();
( D. ?# K* B% G; C - }. p& v N, j, L1 m* Q: w2 t" t
- 9 S: S8 `% l9 ?3 b
- private RenderType getLayers(String texture, int light) {
8 }" P) L6 h, q+ } - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));1 Y" p7 z& r. z+ C( F+ p# a
- }
. @* M3 \1 C3 F! G4 m6 \+ g4 f - 0 ~& Q, q- I' ~ _$ F
- private RenderType getLightTexture(ResourceLocation texture) {
. D# p8 h( K9 d: e- ^3 r - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
; w+ {$ ^8 X% g$ \: _& w$ s) ~ - }
5 e4 ]/ Y( |, \3 z r( d& G
; C3 [8 Y9 ` S' c% F" J- private RenderType getTexture(ResourceLocation texture) {1 ]( i1 B' n" ~
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);8 L' u# c6 s- \! x
- }7 \- A; f" ?5 g# q
- ' k$ m* z$ f3 |1 T
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
3 {/ e; U9 @; h/ ]/ @$ {3 v! h - if (cache.containsKey(identifier)) {9 r3 L+ {0 n! R
- return cache.get(identifier);
7 m8 a$ \& s9 H3 P) `0 ` T - } else {
" O) H$ ]' ?! o2 V( b* F - final RenderType renderLayer = supplier.get();
R5 ^! } L0 C! J2 G5 f - cache.put(identifier, renderLayer);
& u$ U' V$ g- {9 G" M - return renderLayer;
( y& U; F" I7 ^/ \ z i; K/ U - }
# {4 s2 h* e! w# K - }, t% z; u# M% u/ [4 W! T5 ?
- }
复制代码 |
|