random = new Random();
}
@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
TileRepairer repairer = (TileRepairer) par1World.getTileEntity(par2, par3, par4);
ItemStack stack = repairer.getStackInSlot(0);
if (stack == null) {
ItemStack playerStack = par5EntityPlayer.getCurrentEquippedItem();
if (repairer.canInsertItem(0, playerStack, 1)) {
repairer.setInventorySlotContents(0, playerStack.splitStack(1));
if (playerStack.stackSize <= 0)
par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null);
repairer.markDirty();
return true;
}
} else {
if (!par5EntityPlayer.inventory.addItemStackToInventory(stack))
par5EntityPlayer.dropPlayerItemWithRandomChoice(stack, false);
repairer.setInventorySlotContents(0, null);
repairer.markDirty();
return true;
}
return false;
}