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;
|
|
|
|
|
import net.minecraft.item.Item;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2014-02-02 23:18:57 -05:00
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
|
|
|
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-02-02 23:18:57 -05:00
|
|
|
public class TCraftingHandler //implements ICraftingHandler
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
|
2014-02-02 23:18:57 -05:00
|
|
|
@SubscribeEvent
|
|
|
|
|
public void onCrafting (ItemCraftedEvent event)//EntityPlayer player, ItemStack itemstack, IInventory craftMatrix)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-02-02 23:18:57 -05:00
|
|
|
Item item = event.crafting.getItem();
|
|
|
|
|
if (!event.player.worldObj.isRemote)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-01-09 04:08:38 -05:00
|
|
|
if (ComparisonHelper.areEquivalent(item,TRepo.toolStationWood))
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-02-02 23:18:57 -05:00
|
|
|
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(event.player.getDisplayName());
|
|
|
|
|
NBTTagCompound tags = event.player.getEntityData().getCompoundTag("TConstruct");
|
2013-07-26 21:18:53 -07:00
|
|
|
if (!tags.getBoolean("materialManual") || !stats.materialManual)
|
|
|
|
|
{
|
|
|
|
|
stats.materialManual = true;
|
|
|
|
|
tags.setBoolean("materialManual", true);
|
2014-02-02 23:18:57 -05:00
|
|
|
AbilityHelper.spawnItemAtPlayer(event.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-02-02 23:18:57 -05:00
|
|
|
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(event.player.getDisplayName());
|
|
|
|
|
NBTTagCompound tags = event.player.getEntityData().getCompoundTag("TConstruct");
|
2013-07-26 21:18:53 -07:00
|
|
|
if (!tags.getBoolean("smelteryManual") || !stats.smelteryManual)
|
|
|
|
|
{
|
|
|
|
|
stats.smelteryManual = true;
|
|
|
|
|
tags.setBoolean("smelteryManual", true);
|
2014-02-02 23:18:57 -05:00
|
|
|
AbilityHelper.spawnItemAtPlayer(event.player, new ItemStack(TRepo.manualBook, 1, 2));
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
2014-02-02 23:18:57 -05:00
|
|
|
event.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)){
|
2014-02-02 23:18:57 -05:00
|
|
|
event.player.addStat(TAchievements.achievements.get("tconstruct.betterCrafting"), 1);
|
2013-12-19 01:48:06 +11:00
|
|
|
}
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|