Fix #359 Crafting with a worktable does not trigger achievements.

This commit is contained in:
mezz committed 2014-12-06 23:28:05 -08:00
1 parent 84e9673454
commit c010977a0b
3 files changed
+15 -11

No files matched your search

@@ -10,20 +10,22 @@
******************************************************************************/
package forestry.core.gui.slots;
import cpw.mods.fml.common.FMLCommonHandler;
import forestry.core.interfaces.ICrafter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.ItemStack;
import forestry.core.interfaces.ICrafter;
public class SlotCrafter extends Slot {
public class SlotCrafter extends SlotCrafting {
private final ICrafter crafter;
private final IInventory craftMatrix;
public SlotCrafter(IInventory inventory, ICrafter crafter, int slot, int xPos, int yPos) {
super(inventory, slot, xPos, yPos);
public SlotCrafter(EntityPlayer player, IInventory craftMatrix, ICrafter crafter, int slot, int xPos, int yPos) {
super(player, craftMatrix, craftMatrix, slot, xPos, yPos);
this.crafter = crafter;
this.craftMatrix = craftMatrix;
}
@Override
@@ -56,6 +58,8 @@ public class SlotCrafter extends Slot {
@Override
public void onPickupFromSlot(EntityPlayer player, ItemStack itemStack) {
FMLCommonHandler.instance().firePlayerCraftingEvent(player, itemStack, craftMatrix);
this.onCrafting(itemStack, itemStack.stackSize); // handles crafting achievements, maps, and statistics
crafter.takenFromSlot(getSlotIndex(), true, player);
}
}
@@ -20,7 +20,7 @@ public class ContainerFabricator extends ContainerLiquidTanks {
private final MachineFabricator tile;
public ContainerFabricator(InventoryPlayer player, MachineFabricator tile) {
public ContainerFabricator(InventoryPlayer playerInventory, MachineFabricator tile) {
super(tile, tile);
this.tile = tile;
@@ -36,7 +36,7 @@ public class ContainerFabricator extends ContainerLiquidTanks {
this.addSlot(new Slot(tile, MachineFabricator.SLOT_PLAN, 139, 17));
// Result
this.addSlot(new SlotCrafter(tile, tile, MachineFabricator.SLOT_RESULT, 139, 53));
this.addSlot(new SlotCrafter(playerInventory.player, tile, tile, MachineFabricator.SLOT_RESULT, 139, 53));
// Crafting matrix
for (int l = 0; l < 3; l++)
@@ -46,10 +46,10 @@ public class ContainerFabricator extends ContainerLiquidTanks {
// Player inventory
for (int i = 0; i < 3; i++)
for (int k = 0; k < 9; k++)
addSlot(new Slot(player, k + i * 9 + 9, 8 + k * 18, 129 + i * 18));
addSlot(new Slot(playerInventory, k + i * 9 + 9, 8 + k * 18, 129 + i * 18));
// Player hotbar
for (int j = 0; j < 9; j++)
addSlot(new Slot(player, j, 8 + j * 18, 187));
addSlot(new Slot(playerInventory, j, 8 + j * 18, 187));
}
@@ -60,7 +60,7 @@ public class ContainerWorktable extends ContainerForestry implements IContainerC
}
// CraftResult display
addSlot(new SlotCrafter(craftingInventory, tile, TileWorktable.SLOT_CRAFTING_RESULT, 77, 38));
addSlot(new SlotCrafter(player, craftingInventory, tile, TileWorktable.SLOT_CRAFTING_RESULT, 77, 38));
// Player inventory
for (int i1 = 0; i1 < 3; i1++) {