|
|
. V# Y- e- G, F. j8 ?行,这个怎么样6 o* h$ O* B; T7 Z
- package com.xhg78999.mtrfac.render;4 ~9 a7 V8 K9 H {/ _; N, b. z
- w# \/ l7 ~: s* w
- import com.mojang.blaze3d.vertex.PoseStack;
% U: ]5 ?& G- ~$ B! f$ T- [ - import com.mojang.blaze3d.vertex.VertexConsumer;
/ @7 m7 @$ w* b. Q% C f - import net.minecraft.client.renderer.RenderType;
6 ~! o; Q. g! T$ O6 e: F - import net.minecraft.resources.ResourceLocation;) T+ q! g, |+ ?+ y' T
- & |- L' N) C' ?0 y
- import java.util.*;; }$ o4 L( `: `4 g2 h
- & \: `% x! r/ f2 E6 V: }' V
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(- B% ]0 d; a Y+ O) s/ H
$ H. G9 l2 J, |0 {- public class LineRender{
2 ^1 @: Z' O, d' q1 P - private final PoseStack pose;
0 y# I) V3 x9 Y2 c - private final MultiBufferSource source;- E- z9 z: m6 P
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
& G) s& }$ J1 J/ P6 _3 C - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
$ V' E5 k3 n1 p' E - & \1 y6 A( B6 `3 d" d
- 4 ?9 v* `5 g+ t$ O/ I* H
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
3 D& Z6 K" J2 ^3 r - if(x1 == x2 && y1 == y2 && z1 == z2){. J4 l F% r% D0 r* ~" c
- return;
0 Z6 s% R2 B6 A8 {3 X) a - }2 d: W( ^+ [9 M* T- X+ n- [
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){5 M) g' X0 H& n _
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");) u% m: B4 x4 w1 d( O6 U6 b/ w# r( N$ C
- }
# `7 t- x5 j0 @# J - pose.pushPose();
( [- h- P5 n4 ` - final int newLight = convertLight(6);
' p$ ^ i; d5 b3 D( S! u2 k1 k7 r0 _ - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));7 o8 K# ]8 S8 {
- final float lineHeightSmall = (y2 - y1);- i1 G+ \: F. Y3 p/ V* T) |7 |
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);1 d, b4 b) Z+ ?
- pose.popPose();
: O8 g' k) [# ~, \5 v# {$ t - }
: c% R; O& B4 @ P8 I - ; H% [% q$ t4 {7 H
- private RenderType getLayers(String texture, int light) {
- d, m- g: W9 ~5 j8 G7 P - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
$ Q7 w$ s; ~* [" g - }' V4 l" Y) ^3 `" L _0 n
- ( d5 X6 u2 D& e, ~. u+ ^
- private RenderType getLightTexture(ResourceLocation texture) {
3 N- V8 g( L8 l2 D - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
3 m* H1 K6 a; |& L% R0 \ - }# V( n. K9 d0 O! W, C, M+ Q
: ?/ }" T8 |8 c1 F9 `) k. Y9 `5 a- private RenderType getTexture(ResourceLocation texture) {6 i# `1 d P& V; M* f- Q8 `$ q
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
& B/ _+ \, `' X1 L( c, j! |" R - }0 E; o+ l/ P; |7 [
* j4 p4 g1 a- M) e/ F! @5 h- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {" E7 u3 w6 d: v) S( A, Q6 w
- if (cache.containsKey(identifier)) {; C8 g+ _* v8 S* J
- return cache.get(identifier);5 I A- p) u% Q" Y J6 d
- } else {
- I4 r7 q" V4 ~( z3 x$ M ^% s( b' i - final RenderType renderLayer = supplier.get();
: a, R' W; B& |- Z v2 V% _5 j- U - cache.put(identifier, renderLayer);
+ _" O* g6 ]$ C: s0 S - return renderLayer;/ t5 L" M# S: `! o+ [
- }
/ ?# X0 S$ I& x8 ~, j& p* c. c) A - }
& y( R# g# ]) Y+ o3 U% o - }
复制代码 |
|