Jump to content

getEntitiesWithinAABB returning empty list


redgeen

Recommended Posts

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));

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.