package net.minecraft.commands.arguments.coordinates;

import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.ImmutableStringReader;
import com.mojang.brigadier.StringReader;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
import net.minecraft.commands.CommandSourceStack;

public class WorldCoordinates implements Coordinates {
    private final WorldCoordinate x;
    private final WorldCoordinate y;
    private final WorldCoordinate z;
    
    public WorldCoordinates(final WorldCoordinate ep1, final WorldCoordinate ep2, final WorldCoordinate ep3) {
        this.x = ep1;
        this.y = ep2;
        this.z = ep3;
    }
    
    @Override
    public Vec3 getPosition(final CommandSourceStack cz) {
        final Vec3 dem3 = cz.getPosition();
        return new Vec3(this.x.get(dem3.x), this.y.get(dem3.y), this.z.get(dem3.z));
    }
    
    @Override
    public Vec2 getRotation(final CommandSourceStack cz) {
        final Vec2 del3 = cz.getRotation();
        return new Vec2((float)this.x.get(del3.x), (float)this.y.get(del3.y));
    }
    
    @Override
    public boolean isXRelative() {
        return this.x.isRelative();
    }
    
    @Override
    public boolean isYRelative() {
        return this.y.isRelative();
    }
    
    @Override
    public boolean isZRelative() {
        return this.z.isRelative();
    }
    
    @Override
    public boolean equals(final Object object) {
        if (this == object) {
            return true;
        }
        if (!(object instanceof WorldCoordinates)) {
            return false;
        }
        final WorldCoordinates eq3 = (WorldCoordinates)object;
        return this.x.equals(eq3.x) && this.y.equals(eq3.y) && this.z.equals(eq3.z);
    }
    
    public static WorldCoordinates parseInt(final StringReader stringReader) throws CommandSyntaxException {
        final int integer2 = stringReader.getCursor();
        final WorldCoordinate ep3 = WorldCoordinate.parseInt(stringReader);
        if (!stringReader.canRead() || stringReader.peek() != ' ') {
            stringReader.setCursor(integer2);
            throw Vec3Argument.ERROR_NOT_COMPLETE.createWithContext((ImmutableStringReader)stringReader);
        }
        stringReader.skip();
        final WorldCoordinate ep4 = WorldCoordinate.parseInt(stringReader);
        if (!stringReader.canRead() || stringReader.peek() != ' ') {
            stringReader.setCursor(integer2);
            throw Vec3Argument.ERROR_NOT_COMPLETE.createWithContext((ImmutableStringReader)stringReader);
        }
        stringReader.skip();
        final WorldCoordinate ep5 = WorldCoordinate.parseInt(stringReader);
        return new WorldCoordinates(ep3, ep4, ep5);
    }
    
    public static WorldCoordinates parseDouble(final StringReader stringReader, final boolean boolean2) throws CommandSyntaxException {
        final int integer3 = stringReader.getCursor();
        final WorldCoordinate ep4 = WorldCoordinate.parseDouble(stringReader, boolean2);
        if (!stringReader.canRead() || stringReader.peek() != ' ') {
            stringReader.setCursor(integer3);
            throw Vec3Argument.ERROR_NOT_COMPLETE.createWithContext((ImmutableStringReader)stringReader);
        }
        stringReader.skip();
        final WorldCoordinate ep5 = WorldCoordinate.parseDouble(stringReader, false);
        if (!stringReader.canRead() || stringReader.peek() != ' ') {
            stringReader.setCursor(integer3);
            throw Vec3Argument.ERROR_NOT_COMPLETE.createWithContext((ImmutableStringReader)stringReader);
        }
        stringReader.skip();
        final WorldCoordinate ep6 = WorldCoordinate.parseDouble(stringReader, boolean2);
        return new WorldCoordinates(ep4, ep5, ep6);
    }
    
    public static WorldCoordinates current() {
        return new WorldCoordinates(new WorldCoordinate(true, 0.0), new WorldCoordinate(true, 0.0), new WorldCoordinate(true, 0.0));
    }
    
    @Override
    public int hashCode() {
        int integer2 = this.x.hashCode();
        integer2 = 31 * integer2 + this.y.hashCode();
        integer2 = 31 * integer2 + this.z.hashCode();
        return integer2;
    }
}
