|
|
- ~# K9 Q1 X& e9 n E, r
行,这个怎么样; R7 W% W2 P' @! B
- package com.xhg78999.mtrfac.render;
; C: g/ @/ m% k5 S - " M9 P) U; |8 i4 [2 @' g
- import com.mojang.blaze3d.vertex.PoseStack;
9 d* u0 [# F/ S: o6 G0 K! f - import com.mojang.blaze3d.vertex.VertexConsumer;
5 _. c! K9 x, s2 G8 k$ `; y - import net.minecraft.client.renderer.RenderType;
1 I n) [3 a& y& I - import net.minecraft.resources.ResourceLocation;( L3 n3 t5 I( b
; \$ F* V j0 A9 I8 j- import java.util.*;
: H$ ]& _, ]$ W4 ^% y, t3 S8 R; i - / R0 i0 A4 ^5 a+ o. w1 }' @8 m
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(0 ~: C4 q6 C' V, t; }/ M1 U- ?( ~
- # f6 k {5 T$ U' ~% U
- public class LineRender{
, J, ]& z' ?8 |$ d - private final PoseStack pose;
' ]3 @8 [& Q1 E1 \$ a - private final MultiBufferSource source;
' k+ z; ]. t* m2 F; L) s( x- [ - private static final Map<String, RenderType> CACHE_A = new HashMap<>();6 q4 [, L4 s6 b, B
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();- {% q g O, ~
- 5 c1 ^) q/ w& j0 {+ X
- 5 E* {4 o2 c7 Y- G6 M
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){$ y4 P9 p) U, J/ R- h4 v. u
- if(x1 == x2 && y1 == y2 && z1 == z2){" d2 f" q1 f% V# j* c) a8 Z( w' w
- return;7 P5 g& h. j1 v, I
- }
: v: X. @/ v- P! e* V - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){* b# J1 s/ U1 H$ c7 I$ }
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");$ g z* z9 _8 J: Z
- }
: c; E1 N/ Z4 [% t8 m - pose.pushPose();6 R4 T+ X3 S) E$ S
- final int newLight = convertLight(6);
7 q# X- }' w. w+ M1 ]% B - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));$ b* u0 [0 X' c. ^1 D. [" T d
- final float lineHeightSmall = (y2 - y1);
5 V" `' G% s( D- L) {" U5 V3 H - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);, }$ Q% B, Z( q" {) o& T
- pose.popPose();; g6 r0 Q+ n* V, K/ w
- }" Z: K* e2 w5 U
- , c* Z: y: r+ c, k
- private RenderType getLayers(String texture, int light) {
7 d6 Z! z8 @. v8 t( [ - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
7 a b3 l S: a6 S4 ^) Q4 ]: o$ N# w - }' N% F9 Q P0 x5 Z( N
. B4 @$ c" s2 @& J9 ~/ h2 K( t- private RenderType getLightTexture(ResourceLocation texture) {
8 Z* F6 m5 p% K% M+ T - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);" i$ R* N$ p( u! i: a
- }. `( S% _% h: G
- $ j: Y; a& W1 F& u M5 `( u
- private RenderType getTexture(ResourceLocation texture) {
+ F9 O0 E6 {5 s t# \7 l - return this.cache(texture, () -> entityCutout(texture), CACHE_B);1 k3 x x3 f4 U0 j6 |
- }1 |6 Y& i+ l# n7 f) X
( P/ e4 E7 \/ o/ y$ s) z- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {/ k7 a1 }6 Y3 y; W' m F5 c
- if (cache.containsKey(identifier)) {
4 i# N+ F: `, ]0 u! _* | - return cache.get(identifier);
: s4 @' T7 v+ E7 a7 u# e - } else {% m! R- P" B- X
- final RenderType renderLayer = supplier.get();' e8 y" u6 v; W- b: K
- cache.put(identifier, renderLayer);
: @) o) B. D+ L+ b - return renderLayer;
! T, i# Q" L2 F4 k$ z# `& o( M8 ~ - }2 J" u' A. _: w$ s' J+ }
- }
+ r7 \2 i( n6 c9 e0 o8 h* ]! A - }
复制代码 |
|