mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-24 05:44:24 +00:00
Dupe Fix - Make bag logic more lag resistant (#121)
This commit is contained in:
1 parent
4b364a93db
commit
db25dcce48
5 files changed
+14
-5
No files matched your search
@@ -87,7 +87,7 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
|
||||
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 abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
|
||||
return player;
|
||||
}
|
||||
|
||||
public ItemLocation getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public boolean isParentItemInventory(ItemStack itemStack) {
|
||||
ItemStack parent = getParent();
|
||||
return isSameItemInventory(parent, itemStack);
|
||||
|
||||
@@ -33,7 +33,7 @@ public abstract class ItemWithGui extends ItemForestry implements IGuiHandlerIte
|
||||
}
|
||||
|
||||
protected void openGui(EntityPlayer entityplayer) {
|
||||
GuiHandler.openGui(entityplayer, this);
|
||||
GuiHandler.openGui(entityplayer, this, (short) 0, entityplayer.inventory.currentItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,6 +28,11 @@ public class ItemInventoryBackpackPaged extends ItemInventoryBackpack implements
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public class ItemBackpack extends ItemWithGui implements ActivatableFromInventor
|
||||
|
||||
@Override
|
||||
protected void openGui(EntityPlayer entityplayer) {
|
||||
GuiHandler.openGui(entityplayer, this, (short) type.ordinal());
|
||||
GuiHandler.openGui(entityplayer, this, (short) type.ordinal(), entityplayer.inventory.currentItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ItemBackpackNaturalist extends ItemBackpack {
|
||||
|
||||
@Override
|
||||
protected void openGui(EntityPlayer entityplayer) {
|
||||
GuiHandler.openGui(entityplayer, this);
|
||||
GuiHandler.openGui(entityplayer, this, (short) 0, entityplayer.inventory.currentItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user