Skip to content

Commit 6ce2719

Browse files
Fix bag dupe
For real this time. I'm pretty sure
1 parent 843e1d8 commit 6ce2719

File tree

4 files changed

+46
-5
lines changed

4 files changed

+46
-5
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ buildscript {
1717

1818
apply plugin: 'forge'
1919

20-
version = "1.2.4"
20+
version = "1.2.5"
2121
group= "blusunrize"
2222
archivesBaseName = "WitchingGadgets-1.7.10"
2323

src/main/java/witchinggadgets/common/gui/ContainerBag.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.minecraft.inventory.Slot;
88
import net.minecraft.item.ItemStack;
99
import net.minecraft.world.World;
10+
import witchinggadgets.common.WGContent;
1011
import witchinggadgets.common.items.tools.ItemBag;
1112

1213
public class ContainerBag extends Container
@@ -26,7 +27,7 @@ public ContainerBag(InventoryPlayer iinventory, World world)
2627
this.blockedSlot = (iinventory.currentItem + 45);
2728

2829
for (int a = 0; a < pouchSlotAmount; a++) {
29-
this.addSlotToContainer(new Slot(this.input, a, 35 + a % 6 * 18, 9 + a/6 * 18));
30+
this.addSlotToContainer(new SlotBag(this.input, this, a, 35 + a % 6 * 18, 9 + a/6 * 18));
3031
}
3132

3233
bindPlayerInventory(iinventory);
@@ -107,11 +108,32 @@ public void onContainerClosed(EntityPlayer par1EntityPlayer)
107108
if (!this.worldObj.isRemote)
108109
{
109110
((ItemBag)this.pouch.getItem()).setStoredItems(this.pouch, ((InventoryBag)this.input).stackList);
110-
111+
/*
111112
if (!this.player.getCurrentEquippedItem().equals(this.pouch))
112113
this.player.setCurrentItemOrArmor(0, this.pouch);
114+
*/
113115
this.player.inventory.markDirty();
114116
}
115117
}
118+
119+
120+
private boolean isHoldingPouch() {
121+
ItemStack is = this.player.getHeldItem();
122+
return (is != null) && (is.getItem() == WGContent.ItemBag);
123+
}
124+
125+
public void detectAndSendChanges() {
126+
super.detectAndSendChanges();
127+
if ((!this.player.worldObj.isRemote) && (!isHoldingPouch())) {
128+
this.player.closeScreen();
129+
}
130+
}
131+
132+
public void saveCharmPouch() {
133+
if (!this.player.worldObj.isRemote && this.isHoldingPouch()) {
134+
this.player.setCurrentItemOrArmor(0, this.pouch);
135+
//ItemBag.setStoredItems(this.player.getHeldItem(), new ItemStack[] { this.charmInv.getStackInSlot(0), this.charmInv.getStackInSlot(1), this.charmInv.getStackInSlot(2) });
136+
}
137+
}
116138

117139
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package witchinggadgets.common.gui;
2+
3+
import net.minecraft.inventory.IInventory;
4+
import net.minecraft.inventory.Slot;
5+
6+
public class SlotBag extends Slot
7+
{
8+
private final ContainerBag pouchContainer;
9+
10+
public SlotBag(final IInventory inv, final ContainerBag bagContainer, final int id, final int x, final int z) {
11+
super(inv, id, x, z);
12+
this.pouchContainer = bagContainer;
13+
}
14+
15+
public void onSlotChanged() {
16+
super.onSlotChanged();
17+
this.pouchContainer.saveCharmPouch();
18+
}
19+
}

src/main/java/witchinggadgets/common/items/tools/ItemBag.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public void addInformation(ItemStack item, EntityPlayer par2EntityPlayer, List l
180180
}
181181
}
182182

183-
public ItemStack[] getStoredItems(ItemStack item)
183+
public static ItemStack[] getStoredItems(ItemStack item)
184184
{
185185
ItemStack[] stackList = new ItemStack[18];
186186

@@ -202,7 +202,7 @@ public ItemStack[] getStoredItems(ItemStack item)
202202
return stackList;
203203
}
204204

205-
public void setStoredItems(ItemStack item, ItemStack[] stackList)
205+
public static void setStoredItems(ItemStack item, ItemStack[] stackList)
206206
{
207207
NBTTagList inv = new NBTTagList();
208208

0 commit comments

Comments
 (0)