diff --git a/src/main/java/electroblob/wizardry/block/BlockBookshelf.java b/src/main/java/electroblob/wizardry/block/BlockBookshelf.java index b84ed7d8..267cc4b1 100644 --- a/src/main/java/electroblob/wizardry/block/BlockBookshelf.java +++ b/src/main/java/electroblob/wizardry/block/BlockBookshelf.java @@ -29,7 +29,6 @@ import net.minecraft.world.IWorldEventListener; import net.minecraft.world.World; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.Properties; -import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -145,6 +144,31 @@ public class BlockBookshelf extends BlockHorizontal implements ITileEntityProvid return true; } + @Override + public boolean hasComparatorInputOverride(IBlockState state){ + return true; + } + + @Override + public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos){ + + TileEntity tileEntity = world.getTileEntity(pos); + + if(tileEntity instanceof TileEntityBookshelf){ + + int slotsOccupied = 0; + + for(int i = 0; i < ((TileEntityBookshelf)tileEntity).getSizeInventory(); i++){ + if(!((TileEntityBookshelf)tileEntity).getStackInSlot(i).isEmpty()) slotsOccupied++; + } + + return slotsOccupied; + + } + + return super.getComparatorInputOverride(state, world, pos); + } + @Override public boolean eventReceived(IBlockState state, World world, BlockPos pos, int id, int param){ super.eventReceived(state, world, pos, id, param);