Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bag slot handling #55

Merged
merged 3 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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