-
Notifications
You must be signed in to change notification settings - Fork 753
/
TCraftingHandler.java
55 lines (50 loc) · 2.42 KB
/
TCraftingHandler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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 = 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);
AbilityHelper.spawnItemAtPlayer(event.player, new ItemStack(TRepo.manualBook, 1, 1));
}
}
if (ComparisonHelper.areEquivalent(item, TRepo.smeltery) || ComparisonHelper.areEquivalent(item, TRepo.lavaTank))
{
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);
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);
}
}
}
}