diff --git a/src/main/java/forestry/core/inventory/ItemInventory.java b/src/main/java/forestry/core/inventory/ItemInventory.java index e4c0c632cf..88f16fa863 100755 --- a/src/main/java/forestry/core/inventory/ItemInventory.java +++ b/src/main/java/forestry/core/inventory/ItemInventory.java @@ -87,7 +87,7 @@ private void setUID() { public boolean isParentItemEquipped() { return switch (location.type()) { case HELD_BY_PLAYER, UNKNOWN -> isSameItemInventory(player.getCurrentEquippedItem(), parent); - case PLAYER_INVENTORY -> true; + case PLAYER_INVENTORY -> isSameItemInventory(player.inventory.getStackInSlot(location.slotIdx()), parent); }; } @@ -95,6 +95,10 @@ public EntityPlayer getPlayer() { return player; } + public ItemLocation getLocation() { + return location; + } + public boolean isParentItemInventory(ItemStack itemStack) { ItemStack parent = getParent(); return isSameItemInventory(parent, itemStack); diff --git a/src/main/java/forestry/core/items/ItemWithGui.java b/src/main/java/forestry/core/items/ItemWithGui.java index a682de7e16..524bc99c51 100644 --- a/src/main/java/forestry/core/items/ItemWithGui.java +++ b/src/main/java/forestry/core/items/ItemWithGui.java @@ -33,7 +33,7 @@ public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer } protected void openGui(EntityPlayer entityplayer) { - GuiHandler.openGui(entityplayer, this); + GuiHandler.openGui(entityplayer, this, (short) 0, entityplayer.inventory.currentItem); } @Override diff --git a/src/main/java/forestry/storage/inventory/ItemInventoryBackpackPaged.java b/src/main/java/forestry/storage/inventory/ItemInventoryBackpackPaged.java index 7779d74cd1..cc0a196ef3 100644 --- a/src/main/java/forestry/storage/inventory/ItemInventoryBackpackPaged.java +++ b/src/main/java/forestry/storage/inventory/ItemInventoryBackpackPaged.java @@ -28,6 +28,11 @@ public ItemInventoryBackpackPaged(EntityPlayer player, int size, ItemStack items @Override public void flipPage(EntityPlayer player, short page) { - GuiHandler.openGui(player, backpackNaturalist, page); + ItemLocation loc = getLocation(); + if (loc.type() == ItemLocation.Type.PLAYER_INVENTORY) { + GuiHandler.openGui(player, backpackNaturalist, page, loc.slotIdx()); + } else { + GuiHandler.openGui(player, backpackNaturalist, page); + } } } diff --git a/src/main/java/forestry/storage/items/ItemBackpack.java b/src/main/java/forestry/storage/items/ItemBackpack.java index 0f7ea44622..917085bf6c 100755 --- a/src/main/java/forestry/storage/items/ItemBackpack.java +++ b/src/main/java/forestry/storage/items/ItemBackpack.java @@ -72,7 +72,7 @@ public boolean getShareTag() { @Override protected void openGui(EntityPlayer entityplayer) { - GuiHandler.openGui(entityplayer, this, (short) type.ordinal()); + GuiHandler.openGui(entityplayer, this, (short) type.ordinal(), entityplayer.inventory.currentItem); } @Override diff --git a/src/main/java/forestry/storage/items/ItemBackpackNaturalist.java b/src/main/java/forestry/storage/items/ItemBackpackNaturalist.java index 7070a3f7e7..fa64340942 100644 --- a/src/main/java/forestry/storage/items/ItemBackpackNaturalist.java +++ b/src/main/java/forestry/storage/items/ItemBackpackNaturalist.java @@ -34,7 +34,7 @@ public ItemBackpackNaturalist(ISpeciesRoot speciesRoot, IBackpackDefinition defi @Override protected void openGui(EntityPlayer entityplayer) { - GuiHandler.openGui(entityplayer, this); + GuiHandler.openGui(entityplayer, this, (short) 0, entityplayer.inventory.currentItem); } @Override