|
|
& F9 | q3 |. g0 ?' [9 H- t# x行,这个怎么样) C# Y$ y& s# r6 @3 V, A- c
- package com.xhg78999.mtrfac.render;
4 t4 m0 P0 q4 ~- r1 h; r$ v7 t3 }5 \
4 S' X: H- v: o0 [2 u- import com.mojang.blaze3d.vertex.PoseStack;
7 ~; O+ p% n, v: {( L - import com.mojang.blaze3d.vertex.VertexConsumer;6 [7 E! a# p( U5 ~
- import net.minecraft.client.renderer.RenderType;
( S+ C) B" g' |+ c0 O1 W - import net.minecraft.resources.ResourceLocation;* s8 K/ ^ r/ F9 s) j% Z" X9 `
- 2 r: N, f" k0 P6 x9 \
- import java.util.*; u' k% T' E/ ^- H) [
+ Y. y( }7 _+ t7 g; }* ^! Q( E- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(. X/ Y! m6 [( a7 m/ P. X
- ! O; {6 K6 g2 U6 n( {7 _
- public class LineRender{- @+ p2 c2 ^# g
- private final PoseStack pose; W. H/ v2 o. M: }- f% R3 N
- private final MultiBufferSource source;
: [+ z# b( g/ V" _4 E' }5 M - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
+ A) D/ [$ s4 G6 k$ W0 O- ~ - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();9 l5 Z& N; V8 u# R' ]- i' S
# C+ X) ~: b; n$ O0 p7 W+ A1 l- ) S3 W Q, w: @: v4 e+ V+ F
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){' n& k3 ?; i* R! C! d' R- b" S
- if(x1 == x2 && y1 == y2 && z1 == z2){$ u( z U a9 i x5 }8 e! A
- return;3 o2 S: S2 v2 E& P. K
- }( k; n: D H; v* Z4 O3 u. _: q/ t- M- K# g
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
8 T. x, A9 U0 l9 T2 E - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
4 i5 H- P ?* B9 E - }
y1 z0 Y' O, o, x - pose.pushPose();" Q/ W; r8 k: O: q: Z
- final int newLight = convertLight(6);
; ~7 K5 u& O6 [$ x' N+ D. G. @ - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));4 M3 y3 x3 a# N* W% \
- final float lineHeightSmall = (y2 - y1);
* M9 q( ~, {' {; Q0 X - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);, f* V! t# M: l) g* O
- pose.popPose();
3 g; G3 A; \7 h7 [% `9 X5 {4 U - }! i+ x; n0 d0 d# O* ?' S$ s, h) s
! |& e* n2 e& P5 k- q- `- private RenderType getLayers(String texture, int light) {
- L% ]/ t) n: P5 i; K2 L1 y - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture)); ?' a4 M! v+ ?1 _; k
- }1 c, G1 V0 W; W; ~
. x9 g7 a7 [5 m* m# }) z% s- private RenderType getLightTexture(ResourceLocation texture) {
* w7 j( O) d! |- ~7 w - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);: l) N+ [! ~: |& Z- ]
- }. O& j# x. d2 u- A' S
- y* g+ O% a' M
- private RenderType getTexture(ResourceLocation texture) {) J; ?5 B1 n, p; k* R5 y) M
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
4 ~8 R3 X* o+ p0 F" u/ |! h - }
% |2 r2 o3 [8 {; y
$ q7 i& [% B: L* M3 X0 c! f- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {+ D% I; j7 [: ]$ C! I$ q- z
- if (cache.containsKey(identifier)) {1 k$ b1 B; E, v7 `% W0 K, c
- return cache.get(identifier);
9 |; m, z* k& c: `5 @( g( g - } else {
, p! y- S3 d6 Q9 @ - final RenderType renderLayer = supplier.get();; {6 I2 `& r* I* h
- cache.put(identifier, renderLayer);
% D* V& [% q2 R$ T& b3 ` - return renderLayer;5 H! _, g* _7 L9 n% u
- }
/ x/ A k7 G6 G, @) I - } p7 L3 k* o# W( j& e0 F
- }
复制代码 |
|