fixed discarding offhand if it could not be stored
@@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
+import net.minecraft.util.text.TextComponentTranslation;
import se.mickelus.tetra.items.toolbelt.inventory.*;
public class UtilToolbelt {
@@ -31,11 +32,17 @@ public class UtilToolbelt {
}
ItemStack heldItemStack = player.getHeldItem(hand);
-
player.setHeldItem(hand, inventory.takeItemStack(index));
+
if (!heldItemStack.isEmpty()) {
- storeItemInToolbelt(toolbeltStack, heldItemStack);
+ if (!storeItemInToolbelt(toolbeltStack, heldItemStack)) {
+ if (!player.inventory.addItemStackToInventory(heldItemStack)) {
+ inventory.storeItemInInventory(player.getHeldItem(hand));
+ player.setHeldItem(hand, heldItemStack);
+ player.sendStatusMessage(new TextComponentTranslation("toolbelt.blocked"), true);
+ }
+ }
}
}
