Black's way is working perfectly. Thank you to you.
Also here's the code if anyone wants:
@SubscribeEvent
public void OnRightClick(PlayerInteractEvent event){
if (!event.world.isRemote) {
if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
if (event.world.getBlock(event.x, event.y, event.z) == CollectiblesBlocks.collectionBookshelf) {
if (!(event.entityPlayer.getEntityData().hasKey("GOTBOOKON.X."+event.x)&&event.entityPlayer.getEntityData().hasKey("GOTBOOKON.Y."+event.y)&&event.entityPlayer.getEntityData().hasKey("GOTBOOKON.Z."+event.z)))
event.entityPlayer.inventory.addItemStackToInventory(new ItemStack(CollectiblesItems.collectionBook, 1));
event.entityPlayer.getEntityData().setBoolean("GOTBOOKON.X."+event.x,true);
event.entityPlayer.getEntityData().setBoolean("GOTBOOKON.Y."+event.y,true);
event.entityPlayer.getEntityData().setBoolean("GOTBOOKON.Z."+event.z,true);
}
}
}
}