-
Notifications
You must be signed in to change notification settings - Fork 755
/
TCraftingHandler.java
59 lines (52 loc) · 2.26 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
56
57
58
59
package tconstruct.util;
import tconstruct.achievements.TAchievements;
import tconstruct.TConstruct;
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)
{
int itemID = item.getItem().itemID;
if (!player.worldObj.isRemote)
{
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);
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TRepo.manualBook, 1, 1));
}
}
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);
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TRepo.manualBook, 1, 2));
}
player.addStat(TAchievements.achievements.get("tconstruct.smelteryMaker"), 1);
}
if (itemID == TRepo.craftingStationWood.blockID){
player.addStat(TAchievements.achievements.get("tconstruct.betterCrafting"), 1);
}
}
}
@Override
public void onSmelting (EntityPlayer player, ItemStack item)
{
}
}