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

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

import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.asset.util.ColorParseUtil;
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 TintOperation extends ToolOperation
{
    private final int tintColor;
    
    public TintOperation(@Nonnull final Ref<EntityStore> ref, @Nonnull final Player player, @Nonnull final BuilderToolOnUseInteraction packet, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        super(ref, packet, componentAccessor);
        final String colorText = this.args.tool().get("TintColor");
        try {
            this.tintColor = ColorParseUtil.hexStringToRGBInt(colorText);
        }
        catch (final NumberFormatException e) {
            player.sendMessage(Message.translation("server.builderTools.tintOperation.colorParseError").param("value", colorText));
            throw e;
        }
    }
    
    @Override
    public void execute(final ComponentAccessor<EntityStore> componentAccessor) {
        this.builderState.tint(this.x, this.y, this.z, this.tintColor, this.shape, this.shapeRange, this.shapeHeight, componentAccessor);
    }
    
    @Override
    public void executeAt(final int posX, final int posY, final int posZ, final ComponentAccessor<EntityStore> componentAccessor) {
        this.builderState.tint(posX, posY, posZ, this.tintColor, this.shape, this.shapeRange, this.shapeHeight, componentAccessor);
    }
    
    @Override
    boolean execute0(final int x, final int y, final int z) {
        return true;
    }
}
