use of com.minecolonies.coremod.network.messages.TransferItemsRequestMessage in project minecolonies by Minecolonies.
the class WindowHutBuilder method transferItems.
/**
* On Button click transfert Items.
*
* @param button the clicked button.
*/
private void transferItems(@NotNull final Button button) {
final Pane pane = button.getParent();
final Label idLabel = pane.findPaneOfTypeByID(RESOURCE_ID, Label.class);
final int index = Integer.parseInt(idLabel.getLabelText());
final BuildingBuilderResource res = resources.get(index);
if (res == null) {
Log.getLogger().warn("WindowHutBuilder.transferItems: Error - Could not find the resource.");
} else {
// The itemStack size should not be greater than itemStack.getMaxStackSize, We send 1 instead
// and use quantity for the size
@NotNull final ItemStack itemStack = new ItemStack(res.getItem(), 1, res.getDamageValue());
itemStack.setTagCompound(res.getItemStack().getTagCompound());
final Label quantityLabel = pane.findPaneOfTypeByID(RESOURCE_QUANTITY_MISSING, Label.class);
final int quantity = Integer.parseInt(quantityLabel.getLabelText());
MineColonies.getNetwork().sendToServer(new TransferItemsRequestMessage(this.building, itemStack, quantity, true));
}
}
Aggregations