package net.minecraft.core;

import java.util.function.BiFunction;
import com.mojang.datafixers.kinds.Applicative;
import java.util.function.Function;
import com.mojang.datafixers.kinds.App;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import java.util.Objects;
import net.minecraft.world.level.Level;
import net.minecraft.resources.ResourceKey;
import com.mojang.serialization.Codec;

public final class GlobalPos {
    public static final Codec<GlobalPos> CODEC;
    private final ResourceKey<Level> dimension;
    private final BlockPos pos;
    
    private GlobalPos(final ResourceKey<Level> ug, final BlockPos fu) {
        this.dimension = ug;
        this.pos = fu;
    }
    
    public static GlobalPos of(final ResourceKey<Level> ug, final BlockPos fu) {
        return new GlobalPos(ug, fu);
    }
    
    public ResourceKey<Level> dimension() {
        return this.dimension;
    }
    
    public BlockPos pos() {
        return this.pos;
    }
    
    @Override
    public boolean equals(final Object object) {
        if (this == object) {
            return true;
        }
        if (object == null || this.getClass() != object.getClass()) {
            return false;
        }
        final GlobalPos gc3 = (GlobalPos)object;
        return Objects.equals(this.dimension, gc3.dimension) && Objects.equals(this.pos, gc3.pos);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(this.dimension, this.pos);
    }
    
    @Override
    public String toString() {
        return this.dimension.toString() + " " + this.pos;
    }
    
    static {
        CODEC = RecordCodecBuilder.create(instance -> ((RecordCodecBuilder.Instance)instance).group((App)Level.RESOURCE_KEY_CODEC.fieldOf("dimension").forGetter((Function)GlobalPos::dimension), (App)BlockPos.CODEC.fieldOf("pos").forGetter((Function)GlobalPos::pos)).apply(instance, (BiFunction)GlobalPos::of));
    }
}
