mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 11:59:14 +00:00
Finish updating slot logic for Tool Stations, fix dupe bugs
This commit is contained in:
1 parent
c16c376868
commit
2629e241cd
26 files changed
+202
-154
No files matched your search
@@ -1,14 +1,14 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.event.ToolCraftedEvent;
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class SlotTool extends Slot
|
||||
@@ -24,57 +24,53 @@ public class SlotTool extends Slot
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for
|
||||
* the armor slots.
|
||||
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid (ItemStack stack)
|
||||
{
|
||||
return false;
|
||||
// return stack.getItem() instanceof ToolCore;
|
||||
//return stack.getItem() instanceof ToolCore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot (EntityPlayer par1EntityPlayer, ItemStack stack)
|
||||
{
|
||||
this.onCrafting(stack);
|
||||
// stack.setUnlocalizedName("\u00A7f" + toolName);
|
||||
//stack.setUnlocalizedName("\u00A7f" + toolName);
|
||||
super.onPickupFromSlot(par1EntityPlayer, stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes,
|
||||
* not ore and wood. Typically increases an internal count then calls
|
||||
* onCrafting(item).
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
|
||||
* internal count then calls onCrafting(item).
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting (ItemStack stack, int par2)
|
||||
{
|
||||
// this.field_75228_b += par2;
|
||||
//this.field_75228_b += par2;
|
||||
this.onCrafting(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes,
|
||||
* not ore and wood.
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting (ItemStack stack)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
|
||||
if (stack.getItem() instanceof IModifyable)
|
||||
{
|
||||
tags.getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag(((IModifyable) stack.getItem()).getBaseTagName());
|
||||
Boolean full = (inventory.getStackInSlot(2) != null || inventory.getStackInSlot(3) != null);
|
||||
for (int i = 2; i <= 3; i++)
|
||||
inventory.decrStackSize(i, 1);
|
||||
int amount = inventory.getStackInSlot(1).getItem() instanceof ToolCore ? stack.stackSize : 1;
|
||||
ItemStack compare = inventory.getStackInSlot(1);
|
||||
int amount = compare.getItem() instanceof IModifyable ? compare.stackSize : 1;
|
||||
inventory.decrStackSize(1, amount);
|
||||
if (!player.worldObj.isRemote && full)
|
||||
player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "tinker:little_saw", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F);
|
||||
// player.worldObj.playAuxSFX(1021, (int)player.posX,
|
||||
// (int)player.posY, (int)player.posZ, 0);
|
||||
MinecraftForge.EVENT_BUS.post(new ToolCraftedEvent(this.inventory, player, stack));
|
||||
}
|
||||
else //Simply naming items
|
||||
{
|
||||
int amount = inventory.getStackInSlot(1).stackSize;
|
||||
inventory.decrStackSize(1, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user