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 ef1, final WorldCoordinate ef2, final WorldCoordinate ef3) {
        this.x = ef1;
        this.y = ef2;
        this.z = ef3;
    }
    
    @Override
    public Vec3 getPosition(final CommandSourceStack cq) {
        final Vec3 cvl3 = cq.getPosition();
        return new Vec3(this.x.get(cvl3.x), this.y.get(cvl3.y), this.z.get(cvl3.z));
    }
    
    @Override
    public Vec2 getRotation(final CommandSourceStack cq) {
        final Vec2 cvk3 = cq.getRotation();
        return new Vec2((float)this.x.get(cvk3.x), (float)this.y.get(cvk3.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 eg3 = (WorldCoordinates)object;
        return this.x.equals(eg3.x) && this.y.equals(eg3.y) && this.z.equals(eg3.z);
    }
    
    public static WorldCoordinates parseInt(final StringReader stringReader) throws CommandSyntaxException {
        final int integer2 = stringReader.getCursor();
        final WorldCoordinate ef3 = WorldCoordinate.parseInt(stringReader);
        if (!stringReader.canRead() || stringReader.peek() != ' ') {
            stringReader.setCursor(integer2);
            throw Vec3Argument.ERROR_NOT_COMPLETE.createWithContext((ImmutableStringReader)stringReader);
        }
        stringReader.skip();
        final WorldCoordinate ef4 = WorldCoordinate.parseInt(stringReader);
        if (!stringReader.canRead() || stringReader.peek() != ' ') {
            stringReader.setCursor(integer2);
            throw Vec3Argument.ERROR_NOT_COMPLETE.createWithContext((ImmutableStringReader)stringReader);
        }
        stringReader.skip();
        final WorldCoordinate ef5 = WorldCoordinate.parseInt(stringReader);
        return new WorldCoordinates(ef3, ef4, ef5);
    }
    
    public static WorldCoordinates parseDouble(final StringReader stringReader, final boolean boolean2) throws CommandSyntaxException {
        final int integer3 = stringReader.getCursor();
        final WorldCoordinate ef4 = WorldCoordinate.parseDouble(stringReader, boolean2);
        if (!stringReader.canRead() || stringReader.peek() != ' ') {
            stringReader.setCursor(integer3);
            throw Vec3Argument.ERROR_NOT_COMPLETE.createWithContext((ImmutableStringReader)stringReader);
        }
        stringReader.skip();
        final WorldCoordinate ef5 = WorldCoordinate.parseDouble(stringReader, false);
        if (!stringReader.canRead() || stringReader.peek() != ' ') {
            stringReader.setCursor(integer3);
            throw Vec3Argument.ERROR_NOT_COMPLETE.createWithContext((ImmutableStringReader)stringReader);
        }
        stringReader.skip();
        final WorldCoordinate ef6 = WorldCoordinate.parseDouble(stringReader, boolean2);
        return new WorldCoordinates(ef4, ef5, ef6);
    }
    
    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;
    }
}
