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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
package gtPlusPlus.core.slots;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.*;
import net.minecraft.stats.AchievementList;
public class SlotCraftingNoCollect extends SlotCrafting {
/** The craft matrix inventory linked to this result slot. */
private final IInventory craftMatrix;
/** The player that is using the GUI where this slot resides. */
private EntityPlayer thePlayer;
/**
* The number of items that have been crafted so far. Gets passed to
* ItemStack.onCrafting before being reset.
*/
private int amountCrafted;
public SlotCraftingNoCollect(EntityPlayer player, IInventory inventory, IInventory inventory2, int x, int y,
int z) {
super(player, inventory, inventory2, x, y, z);
this.thePlayer = player;
this.craftMatrix = inventory;
}
/**
* Check if the stack is a valid item for this slot. Always true beside for
* the armor slots.
*/
@Override
public boolean isItemValid(ItemStack p_75214_1_) {
return false;
}
/**
* Decrease the size of the stack in slot (first int arg) by the amount of
* the second int arg. Returns the new stack.
*/
@Override
public ItemStack decrStackSize(int amount) {
if (this.getHasStack()) {
this.amountCrafted += Math.min(amount, this.getStack().stackSize);
}
return super.decrStackSize(amount);
}
/**
* the itemStack passed in is the output - ie, iron ingots, and pickaxes,
* not ore and wood. Typically increases an internal count then calls
* onCrafting(item).
*/
@Override
protected void onCrafting(ItemStack output, int amount) {
this.amountCrafted += amount;
this.onCrafting(output);
}
/**
* the itemStack passed in is the output - ie, iron ingots, and pickaxes,
* not ore and wood.
*/
@Override
protected void onCrafting(ItemStack output) {
output.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted);
this.amountCrafted = 0;
if (output.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) {
this.thePlayer.addStat(AchievementList.buildWorkBench, 1);
}
if (output.getItem() instanceof ItemPickaxe) {
this.thePlayer.addStat(AchievementList.buildPickaxe, 1);
}
if (output.getItem() == Item.getItemFromBlock(Blocks.furnace)) {
this.thePlayer.addStat(AchievementList.buildFurnace, 1);
}
if (output.getItem() instanceof ItemHoe) {
this.thePlayer.addStat(AchievementList.buildHoe, 1);
}
if (output.getItem() == Items.bread) {
this.thePlayer.addStat(AchievementList.makeBread, 1);
}
if (output.getItem() == Items.cake) {
this.thePlayer.addStat(AchievementList.bakeCake, 1);
}
if (output.getItem() instanceof ItemPickaxe
&& ((ItemPickaxe) output.getItem()).func_150913_i() != Item.ToolMaterial.WOOD) {
this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1);
}
if (output.getItem() instanceof ItemSword) {
this.thePlayer.addStat(AchievementList.buildSword, 1);
}
if (output.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) {
this.thePlayer.addStat(AchievementList.enchantments, 1);
}
if (output.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) {
this.thePlayer.addStat(AchievementList.bookcase, 1);
}
}
@Override
public void onPickupFromSlot(EntityPlayer player, ItemStack output) {
FMLCommonHandler.instance().firePlayerCraftingEvent(player, output, craftMatrix);
this.onCrafting(output);
/*
* for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) {
* ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);
*
* if (itemstack1 != null) { this.craftMatrix.decrStackSize(i, 1);
*
* if (itemstack1.getItem().hasContainerItem(itemstack1)) { ItemStack
* itemstack2 = itemstack1.getItem().getContainerItem(itemstack1);
*
* if (itemstack2 != null && itemstack2.isItemStackDamageable() &&
* itemstack2.getItemDamage() > itemstack2.getMaxDamage()) {
* MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer,
* itemstack2)); continue; }
*
* if
* (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1)
* || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)) {
* if (this.craftMatrix.getStackInSlot(i) == null) {
* this.craftMatrix.setInventorySlotContents(i, itemstack2); } else {
* this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); } }
* } } }
*/
}
@Override
public boolean canTakeStack(EntityPlayer player) {
return false;
}
}
|