|
|
+ [$ s; q3 a7 \9 k9 z% P
行,这个怎么样. `1 r4 i8 ?. @. R; Y
- package com.xhg78999.mtrfac.render;( u* |# R4 Q" _8 l B/ [' {$ l/ x7 }
- 0 D1 [0 u1 s6 ^2 o
- import com.mojang.blaze3d.vertex.PoseStack;5 k+ K" {: Y+ {3 e2 ^7 Z+ r6 W
- import com.mojang.blaze3d.vertex.VertexConsumer;+ E7 i' V' {+ b) b+ C1 d
- import net.minecraft.client.renderer.RenderType;5 Q% {- L& i3 [
- import net.minecraft.resources.ResourceLocation;
5 H- U9 x/ m) z8 }3 ^
2 v: g5 Q Y0 f: e1 m( F9 p* Q- import java.util.*;
$ W3 W0 z$ i8 r - " o$ ]! y- e/ i# T# Q
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(* J7 o9 d" e$ K% p% Y1 A; `/ N
: A$ V! v, g4 H) X- public class LineRender{
& U8 i* T$ A& D - private final PoseStack pose;& b/ V4 l- f0 n
- private final MultiBufferSource source;3 y' a! Y! r# v( D `
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();
# R* ]3 }3 O! _3 ]. s* A8 [: { - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();, C' \: F& z8 _/ J9 _$ W+ w
x- j. n. {4 w$ r$ K- + B" k7 E ^2 }. v$ h4 M
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
3 F/ F) I& h: m" l$ i# ^ - if(x1 == x2 && y1 == y2 && z1 == z2){
$ b# @ U. |0 C& k, r2 m+ L/ g% }1 C3 z - return;
8 }0 S8 Q7 P; ~( G* I - }
' S/ N# W, o0 o9 C% ~ - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){- a0 i' o: u4 c+ A6 i
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
% Z2 x7 A) |5 p2 J2 ~3 I - }7 l4 N6 O; X( k9 Q# U$ M- n% g
- pose.pushPose();
: e6 q# q5 X# u$ z& Z1 v - final int newLight = convertLight(6);
" _, [6 x7 O @! M+ l' E - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
! h1 y8 M2 @& M9 ~ X6 v1 p - final float lineHeightSmall = (y2 - y1);
8 _% K4 K q# D - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
2 n6 g, p' E: U+ v: L" G - pose.popPose();& z# z# d1 X7 ]
- }
$ G8 p3 S$ g. z2 v3 { - ; y' y+ H# ^9 {5 P5 R
- private RenderType getLayers(String texture, int light) {7 j/ L6 ~: Z. \! O& f
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
9 B: L. o9 `8 T: |: F - }
2 c0 `) U8 @% X8 l" M( ]6 g - 4 M( T' P! A3 t6 q+ [
- private RenderType getLightTexture(ResourceLocation texture) {
' t( h3 m6 _9 B5 l - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
/ N6 m3 l& z9 i. |: o$ T+ X - }
9 Z. m5 k. l: b6 a( P
6 }' i6 X! C$ u$ B& {- private RenderType getTexture(ResourceLocation texture) {
' T5 ]* @8 @4 R W - return this.cache(texture, () -> entityCutout(texture), CACHE_B);
' A4 b. e$ e C( ]+ n - }' _+ ]- f5 i8 e: `
- 0 f q/ s$ b! ~# G& s2 h" u% a
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {$ C$ N; K9 w; u3 Q1 m' e
- if (cache.containsKey(identifier)) {' N+ d/ ?: y% S4 u0 l3 m' C0 c- `
- return cache.get(identifier);
' r+ s5 Z& I- V - } else {
8 V2 |7 v4 ]% f- t* {( E& V- m& x - final RenderType renderLayer = supplier.get();
5 u9 f) g) [' Y5 C5 I) M" K: y - cache.put(identifier, renderLayer);
! {! i: d# \+ [. E' }) G2 D( @ - return renderLayer;
0 X2 R; G; ?* N - }
. m- O4 S4 C* O/ Y) x1 C+ b$ | - }( v0 Y+ k2 ^; l" w0 u8 w: P
- }
复制代码 |
|