Skip to content

Commit

Permalink
fix: 🐛 Fixed stashing to backpack to not work in creative screen beca…
Browse files Browse the repository at this point in the history
…use in this screen there's no serverside processing and thus items actually don't get moved to backpack storage
  • Loading branch information
P3pp3rF1y committed Jan 11, 2025
1 parent 10009d0 commit ba5b6a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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();
Expand Down

0 comments on commit ba5b6a2

Please sign in to comment.