2013-07-26 21:18:53 -07:00
|
|
|
package tconstruct.util;
|
|
|
|
|
|
2013-11-17 19:59:56 +11:00
|
|
|
import tconstruct.achievements.TAchievements;
|
2013-07-26 21:18:53 -07:00
|
|
|
import tconstruct.TConstruct;
|
2013-11-29 23:16:32 -05:00
|
|
|
import tconstruct.common.TRepo;
|
2013-07-26 21:18:53 -07:00
|
|
|
import tconstruct.library.tools.AbilityHelper;
|
|
|
|
|
import tconstruct.util.player.TPlayerStats;
|
2014-01-09 04:08:38 -05:00
|
|
|
import mantle.common.ComparisonHelper;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.inventory.IInventory;
|
2014-01-09 04:08:38 -05:00
|
|
|
import net.minecraft.item.Item;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
import cpw.mods.fml.common.ICraftingHandler;
|
|
|
|
|
|
|
|
|
|
public class TCraftingHandler implements ICraftingHandler
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
@Override
|
2014-01-09 04:08:38 -05:00
|
|
|
public void onCrafting (EntityPlayer player, ItemStack itemstack, IInventory craftMatrix)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-01-09 04:08:38 -05:00
|
|
|
Item item = itemstack.getItem();
|
2013-07-26 21:18:53 -07:00
|
|
|
if (!player.worldObj.isRemote)
|
|
|
|
|
{
|
2014-01-09 04:08:38 -05:00
|
|
|
if (ComparisonHelper.areEquivalent(item,TRepo.toolStationWood))
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-01-08 00:45:09 -05:00
|
|
|
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.getDisplayName());
|
2013-07-26 21:18:53 -07:00
|
|
|
NBTTagCompound tags = player.getEntityData().getCompoundTag("TConstruct");
|
|
|
|
|
if (!tags.getBoolean("materialManual") || !stats.materialManual)
|
|
|
|
|
{
|
|
|
|
|
stats.materialManual = true;
|
|
|
|
|
tags.setBoolean("materialManual", true);
|
2013-11-29 23:16:32 -05:00
|
|
|
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TRepo.manualBook, 1, 1));
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
2014-01-09 04:08:38 -05:00
|
|
|
if (ComparisonHelper.areEquivalent(item,TRepo.smeltery) || ComparisonHelper.areEquivalent(item,TRepo.lavaTank))
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-01-08 00:45:09 -05:00
|
|
|
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.getDisplayName());
|
2013-07-26 21:18:53 -07:00
|
|
|
NBTTagCompound tags = player.getEntityData().getCompoundTag("TConstruct");
|
|
|
|
|
if (!tags.getBoolean("smelteryManual") || !stats.smelteryManual)
|
|
|
|
|
{
|
|
|
|
|
stats.smelteryManual = true;
|
|
|
|
|
tags.setBoolean("smelteryManual", true);
|
2013-11-29 23:16:32 -05:00
|
|
|
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TRepo.manualBook, 1, 2));
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
2013-11-17 22:38:30 +11:00
|
|
|
player.addStat(TAchievements.achievements.get("tconstruct.smelteryMaker"), 1);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
2013-12-19 01:48:06 +11:00
|
|
|
|
2014-01-09 04:08:38 -05:00
|
|
|
if (ComparisonHelper.areEquivalent(item,TRepo.craftingStationWood)){
|
2013-12-19 01:48:06 +11:00
|
|
|
player.addStat(TAchievements.achievements.get("tconstruct.betterCrafting"), 1);
|
|
|
|
|
}
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSmelting (EntityPlayer player, ItemStack item)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|