/* * 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 dimension, BlockPos pos) { public static final MapCodec 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 CODEC = MAP_CODEC.codec(); public static final StreamCodec STREAM_CODEC = StreamCodec.composite(ResourceKey.streamCodec(Registries.DIMENSION), GlobalPos::dimension, BlockPos.STREAM_CODEC, GlobalPos::pos, GlobalPos::of); public static GlobalPos of(ResourceKey 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 dimension, BlockPos pos, int maxDistance) { return this.dimension.equals(dimension) && this.pos.distChessboard(pos) <= maxDistance; } }