Sponge: Inventory contents are not dropped when broken on TE update

Created on 9 Jul 2018  路  5Comments  路  Source: SpongePowered/Sponge

When breaking a block, inside a TileEntity's update method, any items dropped using InventoryHelper.dropInventoryItems are discarded (such as from BlockChest). From what I can tell, they are added to PhaseContext.getBlockItemDropSupplier inside ContainerUtil.performBlockInventoryDrops, but then never consumed.

It's possible there are other cases where this also occurs. I've tried to investigate but I'm afraid I haven't been able to figure much out.

Reproduction code/steps

Firstly, add this method to MixinTileEntityFurnace. You can also do it in a dedicated TE, but this was easier to test with.

@Inject(method = "update", at = @At("HEAD"))
private void onUpdate(CallbackInfo info) {
    if (world.isRemote || world.playerEntities.isEmpty()) return;

    BlockPos pos = getPos().offset(EnumFacing.NORTH);
    IBlockState state = world.getBlockState(pos);
    if (state.getMaterial() == Material.AIR) return;

    EntityPlayer player = world.playerEntities.get(0);
    TileEntity tile = world.getTileEntity(pos);

    state.getBlock().onBlockHarvested(world, pos, state, player);
    if (world.setBlockState(pos, Blocks.AIR.getDefaultState(), world.isRemote ? 11 : 3)) {
        state.getBlock().onBlockDestroyedByPlayer(world, pos, state);
    }
    state.getBlock().harvestBlock(world, player, pos, state, tile, ItemStack.EMPTY);
}
  1. Place a chest in the world and fill it with items
  2. Ctrl+Click the chest to pick it up with NBT.
  3. Place this chest and break it: confirm that items are dropped
  4. Place a furnace.
  5. Place the chest north of this furnace. Confirm is is broken, with only a chest item dropping (but not its contents)
1.12

Most helpful comment

Thank you!

All 5 comments

@SquidDev test with latest SF which can be found here
http://files.minecraftforge.net/spongepowered

@bloodmc I've tested on the latest commit in a development environment with test plugins/mods disabled. I'm happy to set up with an official build as well, but I don't believe it'll make any difference.

OK expect a fix soon.

Fixed in the latest SpongeForge.

Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

XakepSDK picture XakepSDK  路  3Comments

Eufranio picture Eufranio  路  4Comments

JoeSGT picture JoeSGT  路  5Comments

XakepSDK picture XakepSDK  路  4Comments

DarkArc picture DarkArc  路  3Comments