From a80f896a72ed558703d41cee764fbaa80530cf22 Mon Sep 17 00:00:00 2001 From: TheRealWormbo Date: Thu, 4 Jul 2024 20:50:51 +0200 Subject: [PATCH] Use more generic item insert for flower pouch emptying Fixes #4008 and potential similar issues with other multiblock storages. --- .../vazkii/botania/common/item/FlowerPouchItem.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Xplat/src/main/java/vazkii/botania/common/item/FlowerPouchItem.java b/Xplat/src/main/java/vazkii/botania/common/item/FlowerPouchItem.java index cd59c48119..e7305566a0 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/FlowerPouchItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/FlowerPouchItem.java @@ -33,7 +33,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.entity.HopperBlockEntity; import org.jetbrains.annotations.NotNull; @@ -152,19 +151,13 @@ public InteractionResult useOn(UseOnContext ctx) { Direction side = ctx.getClickedFace(); BlockEntity tile = world.getBlockEntity(pos); - if (tile != null) { + if ((ctx.getPlayer() == null || ctx.getPlayer().isSecondaryUseActive()) + && XplatAbstractions.INSTANCE.hasInventory(world, pos, side)) { if (!world.isClientSide) { - Container tileInv; - if (tile instanceof Container container) { - tileInv = container; - } else { - return InteractionResult.FAIL; - } - Container bagInv = getInventory(ctx.getItemInHand()); for (int i = 0; i < bagInv.getContainerSize(); i++) { ItemStack flower = bagInv.getItem(i); - ItemStack rem = HopperBlockEntity.addItem(bagInv, tileInv, flower, side); + ItemStack rem = XplatAbstractions.INSTANCE.insertToInventory(world, pos, side, flower, false); bagInv.setItem(i, rem); }