Modern Industrialization

Modern Industrialization

4M Downloads

Attempt to get block drops from MI barrel/tank without attached block entity can crash the game

James103 opened this issue ยท 2 comments

commented

When an MI barrel or tank is broken or its drops are otherwise retrieved, the mod checks if the block entity, which holds the content of the barrel, is empty or locked when determining whether to copy the block entity data into the barrel to be dropped.
However, mods like Building Gadgets 2 can call the function to get the item which drops from breaking the barrel without the barrel having an attached block entity. This breaks these mods' functionality, which can cause errors or even crash the game.
Original issue: Direwolf20-MC/BuildingGadgets2#143

public ItemStack getCloneItemStack(LevelReader world, BlockPos pos, BlockState state) {
return getStack(world.getBlockEntity(pos));
}

Fixing this will likely need a check to see if the block's block entity is null, and if so returns an empty barrel/tank/appropriate storage unit.

commented

Well for barrels it might be fine to return an empty one.

commented

This should be fixed in BG2. I don't want to add a null check in MI because it would then silently void items.