use of com.minecolonies.coremod.network.messages.AddRemoveRecipeMessage 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);
}
}
use of com.minecolonies.coremod.network.messages.AddRemoveRecipeMessage in project minecolonies by Minecolonies.
the class WindowGuiCrafting method mouseClicked.
@Override
protected void mouseClicked(final int mouseX, final int mouseY, final int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
if (doneButton.isMouseOver()) {
final List<ItemStack> input = new ArrayList<>();
final List<ItemStack> secondaryOutput = new ArrayList<>();
for (int i = 1; i <= CRAFTING_GRID_SIZE; i++) {
final ItemStack stack = inventorySlots.getInventory().get(i);
if (ItemStackUtils.isEmpty(stack)) {
continue;
}
final ItemStack copy = stack.copy();
ItemStackUtils.setSize(copy, 1);
input.add(copy);
if (copy.getItem().hasContainerItem(copy)) {
secondaryOutput.add(copy.getItem().getContainerItem(copy));
}
}
final ItemStack primaryOutput = inventorySlots.getSlot(0).getStack().copy();
if (!ItemStackUtils.isEmpty(primaryOutput)) {
MineColonies.getNetwork().sendToServer(new AddRemoveRecipeMessage(input, 2, primaryOutput, secondaryOutput, building, false));
LanguageHandler.sendPlayerMessage(Minecraft.getMinecraft().player, "com.minecolonies.coremod.gui.recipe.done");
}
}
}
Aggregations