From 7e9cd45f526292b63cd1baa48599ae5fc7a98b96 Mon Sep 17 00:00:00 2001 From: Matthias Mann Date: Tue, 3 Feb 2015 20:27:23 +0100 Subject: [PATCH] give achievements for smelting iron and cooking fish in the alloy smelter --- .../machine/alloy/ContainerAlloySmelter.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/java/crazypants/enderio/machine/alloy/ContainerAlloySmelter.java b/src/main/java/crazypants/enderio/machine/alloy/ContainerAlloySmelter.java index 75309210..46f76c30 100644 --- a/src/main/java/crazypants/enderio/machine/alloy/ContainerAlloySmelter.java +++ b/src/main/java/crazypants/enderio/machine/alloy/ContainerAlloySmelter.java @@ -2,16 +2,18 @@ package crazypants.enderio.machine.alloy; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import net.minecraft.stats.AchievementList; import crazypants.enderio.machine.gui.AbstractMachineContainer; import crazypants.util.Util; public class ContainerAlloySmelter extends AbstractMachineContainer { - private EntityPlayer thePlayer; - private TileAlloySmelter smelter; + private final EntityPlayer thePlayer; + private final TileAlloySmelter smelter; public ContainerAlloySmelter(InventoryPlayer playerInv, TileAlloySmelter te) { super(playerInv, te); @@ -85,18 +87,21 @@ public class ContainerAlloySmelter extends AbstractMachineContainer { @Override protected void onCrafting(ItemStack output) { output.onCrafting(thePlayer.worldObj, thePlayer, numResults); - if(output != null) { - if(!thePlayer.worldObj.isRemote) { - ItemStack outputSized = output.copy(); - outputSized.stackSize = numResults; - float experience = smelter.getExperienceForOutput(outputSized); - Util.giveExperience(thePlayer, experience); - } - + if(!thePlayer.worldObj.isRemote) { + ItemStack outputSized = output.copy(); + outputSized.stackSize = numResults; + float experience = smelter.getExperienceForOutput(outputSized); + Util.giveExperience(thePlayer, experience); } numResults = 0; - } + if(output.getItem() == Items.iron_ingot) { + thePlayer.addStat(AchievementList.acquireIron, 1); + } + if(output.getItem() == Items.cooked_fished) { + thePlayer.addStat(AchievementList.cookFish, 1); + } + } } }