Search in sources :

Example 1 with ChangeRecipePriorityMessage

use of com.minecolonies.coremod.network.messages.ChangeRecipePriorityMessage in project minecolonies by Minecolonies.

the class WindowListRecipes method onButtonClicked.

/**
 * Called when any button has been clicked.
 *
 * @param button the clicked button.
 */
@Override
public void onButtonClicked(@NotNull final Button button) {
    final int row = recipeList.getListElementIndexByPane(button) - 1;
    if (button.getID().equals(BUTTON_REMOVE)) {
        final IRecipeStorage data = recipes.get(row + 1);
        building.removeRecipe(row + 1);
        MineColonies.getNetwork().sendToServer(new AddRemoveRecipeMessage(data, building, true));
    } else if (button.getID().equals(BUTTON_UP)) {
        building.switchIndex(row, row + 1);
        MineColonies.getNetwork().sendToServer(new ChangeRecipePriorityMessage(building, row, true));
    } else if (button.getID().equals(BUTTON_DOWN)) {
        building.switchIndex(row, row - 1);
        MineColonies.getNetwork().sendToServer(new ChangeRecipePriorityMessage(building, row, false));
    } else if (button.getID().equals(BUTTON_CANCEL)) {
        building.openGui(false);
    }
}
Also used : ChangeRecipePriorityMessage(com.minecolonies.coremod.network.messages.ChangeRecipePriorityMessage) IRecipeStorage(com.minecolonies.api.crafting.IRecipeStorage) AddRemoveRecipeMessage(com.minecolonies.coremod.network.messages.AddRemoveRecipeMessage)

Aggregations

IRecipeStorage (com.minecolonies.api.crafting.IRecipeStorage)1 AddRemoveRecipeMessage (com.minecolonies.coremod.network.messages.AddRemoveRecipeMessage)1 ChangeRecipePriorityMessage (com.minecolonies.coremod.network.messages.ChangeRecipePriorityMessage)1