Files
TinkersConstruct/src/main/java/tconstruct/util/TCraftingHandler.java
T
James McKay 244428928c Make TPlayerStats an IExtendedEntityProperties + associated changes
Inventory + Knapsack inventory (and whether you have the manual) is now synced
whenever the player data is (e.g. on disconnect, on changing dimensions and
when going into the menu in SSP.

Other changes:
 * Remove Armor sync packet as it's not needed anymore
 * Move dropping of inventory and knapsack items from TEventHandler to
     TPlayerHandler. Changes to drop items will all other inventory items.
 * Make playerstats store in TPlayerHandler and make it use player UUIDs
     instead of player names (for compatibility with 1.7.6+)
 * Don't sync inventory manually on logging off / changing dimension
     (it's unneeded)
2014-03-06 22:33:35 +11:00

58 lines
2.4 KiB
Java

package tconstruct.util;
import mantle.common.ComparisonHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.TConstruct;
import tconstruct.achievements.TAchievements;
import tconstruct.common.TRepo;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.util.player.TPlayerStats;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
public class TCraftingHandler // implements ICraftingHandler
{
@SubscribeEvent
public void onCrafting (ItemCraftedEvent event)// EntityPlayer player,
// ItemStack itemstack,
// IInventory craftMatrix)
{
Item item = event.crafting.getItem();
if (!event.player.worldObj.isRemote)
{
if (ComparisonHelper.areEquivalent(item, TRepo.toolStationWood))
{
TPlayerStats stats = TPlayerStats.get(event.player);
NBTTagCompound tags = event.player.getEntityData().getCompoundTag("TConstruct");
if (!tags.getBoolean("materialManual") || !stats.materialManual)
{
stats.materialManual = true;
tags.setBoolean("materialManual", true);
AbilityHelper.spawnItemAtPlayer(event.player, new ItemStack(TRepo.manualBook, 1, 1));
}
}
if (ComparisonHelper.areEquivalent(item, TRepo.smeltery) || ComparisonHelper.areEquivalent(item, TRepo.lavaTank))
{
TPlayerStats stats = TPlayerStats.get(event.player);
NBTTagCompound tags = event.player.getEntityData().getCompoundTag("TConstruct");
if (!tags.getBoolean("smelteryManual") || !stats.smelteryManual)
{
stats.smelteryManual = true;
tags.setBoolean("smelteryManual", true);
AbilityHelper.spawnItemAtPlayer(event.player, new ItemStack(TRepo.manualBook, 1, 2));
}
event.player.addStat(TAchievements.achievements.get("tconstruct.smelteryMaker"), 1);
}
if (ComparisonHelper.areEquivalent(item, TRepo.craftingStationWood))
{
event.player.addStat(TAchievements.achievements.get("tconstruct.betterCrafting"), 1);
}
}
}
}