Skip to content

Commit

Permalink
Fix bag slot handling (#55)
Browse files Browse the repository at this point in the history
* fix bag slot handling

* fix slot handling for voidlinked bag

* stop voluminous cloaks from stacking
  • Loading branch information
Lyfts authored Jun 29, 2024
1 parent 152d118 commit 07fb1d7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
15 changes: 10 additions & 5 deletions src/main/java/witchinggadgets/common/gui/ContainerBag.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ public class ContainerBag extends Container {
ItemStack pouch = null;
EntityPlayer player = null;
private int pouchSlotAmount = 18;
private final int hotbarSlot;

public ContainerBag(InventoryPlayer iinventory, World world) {
this.worldObj = world;
this.player = iinventory.player;
this.pouch = iinventory.getCurrentItem();
this.blockedSlot = (iinventory.currentItem + 45);
this.blockedSlot = iinventory.currentItem + 45;
this.hotbarSlot = iinventory.currentItem;

for (int a = 0; a < pouchSlotAmount; a++) {
this.addSlotToContainer(new SlotBag(this.input, this, a, 35 + a % 6 * 18, 9 + a / 6 * 18));
Expand Down Expand Up @@ -82,11 +84,14 @@ public boolean canInteractWith(EntityPlayer entityplayer) {
}

@Override
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer) {
if (par1 == this.blockedSlot || (par2 == 0 && par3 == blockedSlot)) return null;
((ItemBag) this.pouch.getItem()).setStoredItems(this.pouch, ((InventoryBag) this.input).stackList);
public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer player) {
if (slotId == this.blockedSlot || mode == 0 && clickedButton == blockedSlot
|| mode == 2 && clickedButton == hotbarSlot) {
return null;
}
ItemBag.setStoredItems(this.pouch, ((InventoryBag) this.input).stackList);

return super.slotClick(par1, par2, par3, par4EntityPlayer);
return super.slotClick(slotId, clickedButton, mode, player);
}

@Override
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/witchinggadgets/common/gui/ContainerVoidBag.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ public class ContainerVoidBag extends ContainerGhostSlots {
ItemStack pouch = null;
EntityPlayer player = null;
private int pouchSlotAmount = 18;
private final int hotbarSlot;

public ContainerVoidBag(InventoryPlayer iinventory, World world) {
this.worldObj = world;
this.player = iinventory.player;
this.pouch = iinventory.getCurrentItem();
this.blockedSlot = (iinventory.currentItem + 45);
this.blockedSlot = iinventory.currentItem + 45;
this.hotbarSlot = iinventory.currentItem;

for (int a = 0; a < pouchSlotAmount; a++) {
this.addSlotToContainer(new SlotGhostSingleItem(this.input, a, 29 + a % 6 * 20, 7 + a / 6 * 20));
Expand Down Expand Up @@ -81,11 +83,14 @@ public boolean canInteractWith(EntityPlayer entityplayer) {
}

@Override
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer) {
if (par1 == this.blockedSlot || (par2 == 0 && par3 == blockedSlot)) return null;
((ItemBag) this.pouch.getItem()).setStoredItems(this.pouch, ((InventoryBag) this.input).stackList);
public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer player) {
if (slotId == this.blockedSlot || mode == 0 && clickedButton == blockedSlot
|| mode == 2 && clickedButton == hotbarSlot) {
return null;
}
ItemBag.setStoredItems(this.pouch, ((InventoryBag) this.input).stackList);

return super.slotClick(par1, par2, par3, par4EntityPlayer);
return super.slotClick(slotId, clickedButton, mode, player);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemSta
return new ModelCloak(getColor(itemStack));
}

@Override
public int getItemStackLimit(ItemStack stack) {
return subNames[stack.getItemDamage()].equals("storage") ? 1 : maxStackSize;
}

@Override
public String getUnlocalizedName(ItemStack stack) {
return getUnlocalizedName() + "." + subNames[stack.getItemDamage()];
Expand Down

0 comments on commit 07fb1d7

Please sign in to comment.