Skip to content

Commit

Permalink
Use more generic item insert for flower pouch emptying
Browse files Browse the repository at this point in the history
Fixes #4008 and potential similar issues with other multiblock storages.
  • Loading branch information
TheRealWormbo committed Jul 6, 2024
1 parent 4edd531 commit a80f896
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

Expand Down

0 comments on commit a80f896

Please sign in to comment.