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

59 lines
2.3 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;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.ICraftingHandler;
public class TCraftingHandler implements ICraftingHandler
{
@Override
public void onCrafting (EntityPlayer player, ItemStack item, IInventory craftMatrix)
{
2013-11-17 19:59:56 +11:00
int itemID = item.getItem().itemID;
if (!player.worldObj.isRemote)
{
2013-11-29 23:16:32 -05:00
if (itemID == TRepo.toolStationWood.blockID)
{
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username);
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-11-29 23:16:32 -05:00
if (itemID == TRepo.smeltery.blockID || itemID == TRepo.lavaTank.blockID)
{
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username);
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-11-17 22:38:30 +11:00
player.addStat(TAchievements.achievements.get("tconstruct.smelteryMaker"), 1);
}
2013-12-19 01:48:06 +11:00
if (itemID == TRepo.craftingStationWood.blockID){
player.addStat(TAchievements.achievements.get("tconstruct.betterCrafting"), 1);
}
}
}
@Override
public void onSmelting (EntityPlayer player, ItemStack item)
{
}
}