When I run @Override onItemRightClick it works just fine returning list of items around me
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
playerIn.swingArm(handIn);
double x = playerIn.getPosX() ;
double y = playerIn.getPosY() /*+ 1.0d*/;
double z = playerIn.getPosZ();
AxisAlignedBB playerRange = new AxisAlignedBB(x - 3.0f, y - 3.0f, z - 3.0f, x + 3.0f,y + 3.0f,z + 3.0f);
System.out.println(playerIn.getEntityWorld().getEntitiesWithinAABB(ItemEntity.class,playerRange));
But when I try same thing using @SubscribeEvent I get empty list, why?
@SubscribeEvent
public static void RightClickItem(PlayerInteractEvent.RightClickItem event) {
double x = event.getPlayer().getPosX() ;
double y = event.getPlayer().getPosX() /*+ 1.0d*/;
double z = event.getPlayer().getPosX();
AxisAlignedBB playerRange = new AxisAlignedBB(x - 3.0f, y - 3.0f, z - 3.0f, x + 3.0f,y + 3.0f,z + 3.0f);
System.out.println(event.getWorld().getEntitiesWithinAABB(ItemEntity.class,playerRange));