|
|
( L1 O' Y: y# _3 G行,这个怎么样
: M% F& t1 Y4 j* y7 E5 R- package com.xhg78999.mtrfac.render;7 A7 T) m$ C4 h: ^9 A, Z* ]
- " ^. l) l, I- y: p+ f9 u0 \7 X
- import com.mojang.blaze3d.vertex.PoseStack;
# ?. Y! z) J) t2 m: P( j: y - import com.mojang.blaze3d.vertex.VertexConsumer;1 ?. r9 l0 M) h( s9 N& r' N
- import net.minecraft.client.renderer.RenderType;% t& R- e: ?+ v3 |
- import net.minecraft.resources.ResourceLocation;" }) T; \6 o: S! y
- L- O2 A3 m4 Q- ^- import java.util.*;
) j! N! ] J; r7 ]7 V8 K
$ Q3 w$ p3 ?8 |2 P- s- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(' Q8 o! K* H: I' f4 l! i f) e1 s
- 1 J: c, ]8 w9 p) c
- public class LineRender{- ?* M( h' `' \3 e: ?
- private final PoseStack pose;( q0 q* T% F% ~6 k* g
- private final MultiBufferSource source;( U6 o1 \ o: f
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
- Z, P$ f' g; J; |: w - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
( D: d8 O1 e4 e1 v - 6 d" t! P; g* G) o) H9 y
4 a/ O* H+ d, x) p, |5 d- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
- M8 ]' E' v! N+ F1 s - if(x1 == x2 && y1 == y2 && z1 == z2){2 q( h" [. ]- G4 F3 S9 H
- return;. D- e7 f( Q) m) ]
- }* z' N1 D4 j& j, K8 _/ P
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
+ Z8 {$ m8 L! p& b - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
% u+ T ^6 W/ o! T" M - }
5 C0 x) I& U( T2 m& M' I - pose.pushPose();
: z1 C) {% {5 i6 V0 R9 P - final int newLight = convertLight(6);8 Q: ]- K; U2 D2 q; p! ?
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));7 g: }! \6 G( F6 W, F
- final float lineHeightSmall = (y2 - y1);$ m) [& i; B! K/ v
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);& T: \) P3 W" ^# Z+ v7 H
- pose.popPose();# }* ~- k$ ?0 e! \/ x
- }$ L3 K" h9 i; u* ^" X9 I3 c- d
. U. H1 f! u7 s$ C- private RenderType getLayers(String texture, int light) {1 i/ i3 n5 V6 a6 e2 v u
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));8 C; o9 E P% d* N: ]2 `
- }, i) h, s: X0 t9 l: T) C
- : Q. i; r+ T9 n8 B- ~
- private RenderType getLightTexture(ResourceLocation texture) {
h w6 i) I; [' Z - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);- @' l1 F; }' [& e5 |1 Y
- }
: ?) [; `4 @! V% j
- s1 C* }+ w$ d/ @* y5 o# Z- private RenderType getTexture(ResourceLocation texture) {
5 q) Q+ Y9 p& S - return this.cache(texture, () -> entityCutout(texture), CACHE_B);: m) m7 F! W4 m) g
- }# ~( m3 x: s+ L( m/ B
- % V, W8 L. j/ e2 T+ m% A0 W0 g' M
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
& B. U2 l; F# U% ]. o) f - if (cache.containsKey(identifier)) {
% b1 u# w' L9 q4 l% Y - return cache.get(identifier);
) [$ v3 S, E% W - } else {8 H& L$ G" o; e9 O3 \3 x7 b- Z
- final RenderType renderLayer = supplier.get();8 D" j- V l1 N- L
- cache.put(identifier, renderLayer);8 U) o9 M" n4 l1 e7 w% m
- return renderLayer;9 d* D" y0 V. i* ^! v
- }# a" D M( r' b+ y
- }* A4 O# }) {$ F ~! E
- }
复制代码 |
|