Fix nametag logic in toolforge and fix anything performed on a tool not consuming materials #1438

This commit is contained in:
Bernhard Bonigl committed 2015-03-02 15:20:44 +01:00
1 parent 22e6378e16
commit 5c6b0b257e
3 files changed
+13 -2

No files matched your search

@@ -54,7 +54,7 @@ public class SlotTool extends Slot
*/
protected void onCrafting (ItemStack stack)
{
if (stack.getItem() instanceof IModifyable && inventory.getStackInSlot(1) != null && !(inventory.getStackInSlot(1).getItem() instanceof IModifyable))
if (stack.getItem() instanceof IModifyable)
{
NBTTagCompound tags = stack.getTagCompound().getCompoundTag(((IModifyable) stack.getItem()).getBaseTagName());
Boolean full = (inventory.getStackInSlot(2) != null || inventory.getStackInSlot(3) != null);
@@ -2,6 +2,7 @@ package tconstruct.tools.inventory;
import java.util.Random;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -39,6 +40,13 @@ public class SlotToolForge extends SlotTool
{
int amount = inventory.getStackInSlot(1).stackSize;
inventory.decrStackSize(1, amount);
for(int i = 0; i < inventory.getSizeInventory(); i++) {
if(inventory.getStackInSlot(i) != null && inventory.getStackInSlot(i).getItem() == Items.name_tag) {
inventory.decrStackSize(i, 1);
break;
}
}
}
}
}
@@ -146,9 +146,12 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
}
// we only allow renaming with a nametag otherwise
else if (!("\u00A7f" + name).equals(display.getString("Name")) && !name.equals(display.getString("Name"))) {
int nametagCount = 0;
for(int i = 0; i < inventory.length; i++)
if(inventory[i] != null && inventory[i].getItem() == Items.name_tag)
doRename = true;
nametagCount++;
doRename = nametagCount == 1;
}
if(!doRename)