mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-14 01:14:18 +00:00
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)
58 lines
2.4 KiB
Java
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|