From ba5b6a22e1d6a8f226362c444c55c242eb61c015 Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Sat, 11 Jan 2025 23:49:14 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fixed=20stashing=20to=20b?= =?UTF-8?q?ackpack=20to=20not=20work=20in=20creative=20screen=20because=20?= =?UTF-8?q?in=20this=20screen=20there's=20no=20serverside=20processing=20a?= =?UTF-8?q?nd=20thus=20items=20actually=20don't=20get=20moved=20to=20backp?= =?UTF-8?q?ack=20storage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../sophisticatedbackpacks/backpack/BackpackItem.java | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index af880875..085cce08 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.daemon=false mod_id=sophisticatedbackpacks mod_group_id=sophisticatedbackpacks -mod_version=3.22.0 +mod_version=3.22.1 sonar_project_key=sophisticatedbackpacks:SophisticatedBackpacks github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedBackpacks diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackItem.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackItem.java index 3812a323..325c88af 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackItem.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackItem.java @@ -3,6 +3,7 @@ import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -412,7 +413,7 @@ public ItemStack getBackpack() { @Override public boolean overrideStackedOnOther(ItemStack storageStack, Slot slot, ClickAction action, Player player) { - if (storageStack.getCount() > 1 || !slot.mayPickup(player) || action != ClickAction.SECONDARY) { + if (hasCreativeScreenContainerOpen(player) || storageStack.getCount() > 1 || !slot.mayPickup(player) || action != ClickAction.SECONDARY) { return super.overrideStackedOnOther(storageStack, slot, action, player); } @@ -436,7 +437,7 @@ public boolean overrideStackedOnOther(ItemStack storageStack, Slot slot, ClickAc @Override public boolean overrideOtherStackedOnMe(ItemStack storageStack, ItemStack otherStack, Slot slot, ClickAction action, Player player, SlotAccess carriedAccess) { - if (storageStack.getCount() > 1 || !slot.mayPlace(storageStack) || action != ClickAction.SECONDARY) { + if (hasCreativeScreenContainerOpen(player) || storageStack.getCount() > 1 || !slot.mayPlace(storageStack) || action != ClickAction.SECONDARY) { return super.overrideOtherStackedOnMe(storageStack, otherStack, slot, action, player, carriedAccess); } @@ -450,6 +451,10 @@ public boolean overrideOtherStackedOnMe(ItemStack storageStack, ItemStack otherS return super.overrideOtherStackedOnMe(storageStack, otherStack, slot, action, player, carriedAccess); } + private boolean hasCreativeScreenContainerOpen(Player player) { + return player.containerMenu instanceof CreativeModeInventoryScreen.ItemPickerMenu; + } + @Override public boolean canFitInsideContainerItems() { return Config.SERVER.canBePlacedInContainerItems.get();