Files
TinkersConstruct/src/main/java/tconstruct/util/TCraftingHandler.java
T

54 lines
2.4 KiB
Java
Raw Normal View History

package tconstruct.util;
2013-11-17 19:59:56 +11:00
import tconstruct.achievements.TAchievements;
import tconstruct.TConstruct;
2013-11-29 23:16:32 -05:00
import tconstruct.common.TRepo;
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;
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;
2014-02-02 23:18:57 -05:00
public class TCraftingHandler //implements ICraftingHandler
{
2014-02-02 23:18:57 -05:00
@SubscribeEvent
public void onCrafting (ItemCraftedEvent event)//EntityPlayer player, ItemStack itemstack, IInventory craftMatrix)
{
2014-02-02 23:18:57 -05:00
Item item = event.crafting.getItem();
if (!event.player.worldObj.isRemote)
{
2014-01-09 04:08:38 -05:00
if (ComparisonHelper.areEquivalent(item,TRepo.toolStationWood))
{
2014-02-02 23:18:57 -05:00
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(event.player.getDisplayName());
NBTTagCompound tags = event.player.getEntityData().getCompoundTag("TConstruct");
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));
}
}
2014-01-09 04:08:38 -05:00
if (ComparisonHelper.areEquivalent(item,TRepo.smeltery) || ComparisonHelper.areEquivalent(item,TRepo.lavaTank))
{
2014-02-02 23:18:57 -05:00
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(event.player.getDisplayName());
NBTTagCompound tags = event.player.getEntityData().getCompoundTag("TConstruct");
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));
}
2014-02-02 23:18:57 -05:00
event.player.addStat(TAchievements.achievements.get("tconstruct.smelteryMaker"), 1);
}
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
}
}
}
}