2025-11-24 22:52:51 +03:00

45 lines
1.9 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.mojang.datafixers.kinds.App
* com.mojang.datafixers.kinds.Applicative
* com.mojang.serialization.Codec
* com.mojang.serialization.MapCodec
* com.mojang.serialization.codecs.RecordCodecBuilder
* io.netty.buffer.ByteBuf
*/
package net.minecraft.core;
import com.mojang.datafixers.kinds.App;
import com.mojang.datafixers.kinds.Applicative;
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import io.netty.buffer.ByteBuf;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.Level;
public record GlobalPos(ResourceKey<Level> dimension, BlockPos pos) {
public static final MapCodec<GlobalPos> MAP_CODEC = RecordCodecBuilder.mapCodec(i -> i.group((App)Level.RESOURCE_KEY_CODEC.fieldOf("dimension").forGetter(GlobalPos::dimension), (App)BlockPos.CODEC.fieldOf("pos").forGetter(GlobalPos::pos)).apply((Applicative)i, GlobalPos::of));
public static final Codec<GlobalPos> CODEC = MAP_CODEC.codec();
public static final StreamCodec<ByteBuf, GlobalPos> STREAM_CODEC = StreamCodec.composite(ResourceKey.streamCodec(Registries.DIMENSION), GlobalPos::dimension, BlockPos.STREAM_CODEC, GlobalPos::pos, GlobalPos::of);
public static GlobalPos of(ResourceKey<Level> dimension, BlockPos pos) {
return new GlobalPos(dimension, pos);
}
@Override
public String toString() {
return String.valueOf(this.dimension) + " " + String.valueOf(this.pos);
}
public boolean isCloseEnough(ResourceKey<Level> dimension, BlockPos pos, int maxDistance) {
return this.dimension.equals(dimension) && this.pos.distChessboard(pos) <= maxDistance;
}
}