Skip to content

Commit

Permalink
Fix nametag logic in toolforge and fix anything performed on a tool n…
Browse files Browse the repository at this point in the history
…ot consuming materials #1438
  • Loading branch information
bonii-xx committed Mar 2, 2015
1 parent 22e6378 commit 5c6b0b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/tools/inventory/SlotTool.java
Expand Up @@ -54,7 +54,7 @@ protected void onCrafting (ItemStack stack, int par2)
*/
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);
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/tconstruct/tools/inventory/SlotToolForge.java
Expand Up @@ -2,6 +2,7 @@

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;
Expand Down Expand Up @@ -39,6 +40,13 @@ protected void onCrafting (ItemStack stack)
{
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;
}
}
}
}
}
5 changes: 4 additions & 1 deletion src/main/java/tconstruct/tools/logic/ToolStationLogic.java
Expand Up @@ -146,9 +146,12 @@ else if (tags.getCompoundTag("display").hasKey("Name"))
}
// 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)
Expand Down

0 comments on commit 5c6b0b2

Please sign in to comment.