|
|
" k* M5 K7 S% @& L8 e3 q. I
行,这个怎么样
6 k% r6 {8 r$ V6 W! D4 J J+ V- package com.xhg78999.mtrfac.render; g5 J3 b& u. H% w
( s% U; x( j5 y- import com.mojang.blaze3d.vertex.PoseStack;% p% |6 D- C9 q+ e
- import com.mojang.blaze3d.vertex.VertexConsumer;
6 k" j! N6 g- A* s' I0 W - import net.minecraft.client.renderer.RenderType;3 B/ T( ~9 u5 R& S; v
- import net.minecraft.resources.ResourceLocation;: _' r/ R- ~5 C0 M4 m
8 t+ {9 i% q- M- import java.util.*;% l+ |4 H. E6 W
7 C9 s7 A2 u0 A* l; @4 G$ K; E- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(: c" l8 e3 C3 f0 Z9 |
- 5 n" m* V( n6 P8 u9 X$ w
- public class LineRender{
0 B6 `$ x; p+ ? - private final PoseStack pose;- L( t$ T7 R9 ~, @- {
- private final MultiBufferSource source;+ g0 e8 x; N1 p! |6 I0 |6 _
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();% h/ |4 E# N9 G/ I/ y7 A9 J/ P
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
" ?* q q4 Z) U" P: e - 8 J* q8 r) {( S& g2 _
- U; V( P9 [4 D; K8 L& u+ [( ?- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
9 {" y: v8 S( I. `8 h - if(x1 == x2 && y1 == y2 && z1 == z2){" z6 J8 O. k! B7 v4 Z, \
- return;, d; o/ d3 `/ t/ z
- }$ ~* W' i# ?# n# H$ f
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
k& z: c# q; L6 J! |& c - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");( \7 ]6 m$ r5 D5 w; [" e% f A: L3 t$ q
- }( q8 r& ? o# F9 J
- pose.pushPose();. p3 r3 r1 J% u* ]4 E0 C
- final int newLight = convertLight(6);
( P- r! C! X& U, s7 D7 P& [* n - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));& r. K* L# ?5 t* J; F+ h
- final float lineHeightSmall = (y2 - y1);) \3 s7 S: K4 n( Y! T& Y1 s, f
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
$ a! T( F# a. E* t3 V* c - pose.popPose();; {0 c# W7 d3 i8 T5 a
- }
8 p; S `8 Z+ k. e% U - ; E/ \/ N" s5 x& z, f7 g/ t7 d
- private RenderType getLayers(String texture, int light) {. I8 d' ~2 d- }- u6 s" ^
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
& f) d _( g0 a; r7 `# O - }+ F/ X. \( d1 g( {; k2 A: g& U& P
- $ D& w% v6 r" p, T4 p$ ]
- private RenderType getLightTexture(ResourceLocation texture) {/ f% N E/ y4 h2 U( `* l4 e p0 o K
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
2 h% c F/ e1 C& ]0 A9 F, c - }+ v$ S8 E6 C/ Z8 {$ S# @
; Q* t, [4 w2 B7 Q- private RenderType getTexture(ResourceLocation texture) {
4 ~6 q5 f0 u0 {& d, E - return this.cache(texture, () -> entityCutout(texture), CACHE_B);* m4 C4 Z I$ J; u+ W" j, P
- }# h* C* H# e' s4 y
- / }4 ]7 f$ h" y |6 ~
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
6 R Y* V( h$ G5 F) P! B6 T) @ - if (cache.containsKey(identifier)) {
* O( A3 a5 f7 r! G1 z3 H: @ - return cache.get(identifier);
/ ~2 D$ ?: H. j; ]) Q. H - } else {
+ Z( S6 y( k- S6 J; {1 S; \ - final RenderType renderLayer = supplier.get();+ n4 F* E) R8 t. j5 J
- cache.put(identifier, renderLayer);
# [+ \; v* j# ?( M" D3 L- H2 K - return renderLayer;6 C6 P* `: {1 J, g' w# _" i
- }. S4 d( _( d0 e3 M |7 }
- }
, n2 r" y6 W$ N& q$ x& p0 u - }
复制代码 |
|