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

package com.hypixel.hytale.builtin.buildertools.tooloperations;

import com.hypixel.hytale.builtin.buildertools.BuilderToolsPlugin;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.prefab.selection.mask.BlockPattern;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.protocol.packets.buildertools.BuilderToolOnUseInteraction;
import com.hypixel.hytale.server.core.entity.entities.Player;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.Ref;

public class FloodOperation extends ToolOperation
{
    public FloodOperation(@Nonnull final Ref<EntityStore> ref, @Nonnull final Player player, @Nonnull final BuilderToolOnUseInteraction packet, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        super(ref, packet, componentAccessor);
    }
    
    @Override
    public void execute(final ComponentAccessor<EntityStore> componentAccessor) {
        final BlockPattern targetPattern = this.args.tool().get("TargetBlock");
        final int targetBlock = targetPattern.isEmpty() ? this.edit.getAccessor().getBlock(this.x, this.y, this.z) : targetPattern.firstBlock();
        final Player playerComponent = componentAccessor.getComponent(this.playerRef, Player.getComponentType());
        assert playerComponent != null;
        final PlayerRef playerRefComponent = componentAccessor.getComponent(this.playerRef, PlayerRef.getComponentType());
        assert playerRefComponent != null;
        BuilderToolsPlugin.getState(playerComponent, playerRefComponent).flood(this.edit, this.x, this.y + this.originOffsetY, this.z, this.shapeRange, this.shapeHeight, this.pattern, targetBlock);
    }
    
    @Override
    boolean execute0(final int x, final int y, final int z) {
        return true;
    }
}
