// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.core.universe.world.commands.block;

import com.hypixel.hytale.server.core.command.system.arguments.system.Argument;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgumentType;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;

public class BlockSetStateCommand extends SimpleBlockCommand
{
    private final RequiredArg<String> stateArg;
    
    public BlockSetStateCommand() {
        super("setstate", "");
        this.stateArg = this.withRequiredArg("state", "", ArgTypes.STRING);
    }
    
    @Override
    protected void executeWithBlock(@Nonnull final CommandContext context, @Nonnull final WorldChunk chunk, final int x, final int y, final int z) {
        final int blockId = chunk.getBlock(x, y, z);
        final BlockType blockType = BlockType.getAssetMap().getAsset(blockId);
        final String state = context.get((Argument<?, String>)this.stateArg);
        chunk.setBlockInteractionState(x, y, z, blockType, state, true);
    }
}
