[ANGRY PIXEL] The Betweenlands

[ANGRY PIXEL] The Betweenlands

24M Downloads

Compost bin, duplication item

Opened this issue · 5 comments

commented

Hi, sorry my english.

If you break a working compost bin, items in it will drop in huge quantities.

2019-11-14-00-32-45

Minecraft: 1.12.2
Forge: 14.23.5.2847
The BetweenLands: 3.5.1
Mods:
изображение

commented

Can confirm, this issue is very reproducible. It seems to give you exactly 64 times the items you put into it. Works with any compostable item.

commented

Works regardless of whether you start breaking it from open or closed.

commented

Confirmed in fresh development environment using the 3.5.1 release

commented

Seems to be the result of a hack that was implemented for hopper compat not interacting well with the InventoryHelper's method of dropping items

commented

Proposed solution: replace breakBlock in BlockCompostBin with the following:

@Override
	public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
		TileEntity tileEntity = worldIn.getTileEntity(pos);
		
		if (tileEntity instanceof IInventory) {
			
			//InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileEntity);
			TileEntityCompostBin bin = (TileEntityCompostBin)tileEntity;
			NonNullList<ItemStack> inventory = bin.getInventory();
			for(ItemStack stack : inventory)
			{
				ItemStack buffer = stack;
				buffer.setCount(1);
				
				bin.getWorld().spawnEntity(new EntityItem(bin.getWorld(), bin.getPos().getX(), bin.getPos().getY(), bin.getPos().getZ(), buffer));
			}
			worldIn.updateComparatorOutputLevel(pos, this);
		}

		super.breakBlock(worldIn, pos, state);
	}

Requires a getter for the field inventory in TileEntityCompostBin of course.