Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.9] getCollisionBoundingBox() switched with getSelectedBoundingBox() ?

Featured Replies

Posted

Is it possible that these two methods might be misnamed?

 

The following sample code works:

@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, World worldIn, BlockPos pos)
{
   return Block.FULL_BLOCK_AABB;
}

@Override
public AxisAlignedBB getSelectedBoundingBox(IBlockState blockState, World worldIn, BlockPos pos)
{
   if (myBlockShouldBeSolid)
   {
      return Block.FULL_BLOCK_AABB; // solid
   }
   return Block.NULL_AABB; // not solid
}

 

But shouldn't this code actually be?

@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, World worldIn, BlockPos pos)
{
   if (myBlockShouldBeSolid)
   {
      return Block.FULL_BLOCK_AABB; // solid
   }
   return Block.NULL_AABB; // not solid
}

@Override
public AxisAlignedBB getSelectedBoundingBox(IBlockState blockState, World worldIn, BlockPos pos)
{
   return NULL_AABB;
}

nop

is only than now thay changed becoze after all are from the same kind

 

i have to change the code for mi mod lozas to this so i could mach the bounding box and the collision box

 

// ###########################################################3
@Override
    public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
    {
       	EnumFacing enumfacing = (EnumFacing) state.getValue(FACING);
    		int	ifacing = enumfacing.getIndex();
    		
    		AxisAlignedBB bb = new AxisAlignedBB(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);

			switch (ifacing) {
			default: // up
				bb = new AxisAlignedBB(0.0F, 0.66F, 0.0F, 1.0F, 1.0F, 1.0F);
				break;
			case 1: // down
				bb = new AxisAlignedBB(0.0F, 0.0F, 0.0F, 1.0F, 0.33F, 1.0F);
				break;
			case 2: // north
				bb = new AxisAlignedBB(0.0F, 0.0F, 0.66F, 1.0F, 1.0F, 1.0F);
				break;
			case 3: // south
				bb = new AxisAlignedBB(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.33F);
				break;
			case 4: // west
				bb = new AxisAlignedBB(0.66F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
				break;
			case 5: // east
				bb = new AxisAlignedBB(0.0F, 0.0F, 0.0F, 0.33F, 1.0F, 1.0F);
				break;

			}

        return bb;
    }

// ###########################################################3
@Override
    public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World worldIn, BlockPos pos)
    {
       	EnumFacing enumfacing = (EnumFacing) state.getValue(FACING);
    		int	ifacing = enumfacing.getIndex();
    		
    		AxisAlignedBB bb = new AxisAlignedBB(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);

			switch (ifacing) {
			default: // up
				bb = new AxisAlignedBB(0.0F, 0.66F, 0.0F, 1.0F, 1.0F, 1.0F);
				break;
			case 1: // down
				bb = new AxisAlignedBB(0.0F, 0.0F, 0.0F, 1.0F, 0.33F, 1.0F);
				break;
			case 2: // north
				bb = new AxisAlignedBB(0.0F, 0.0F, 0.66F, 1.0F, 1.0F, 1.0F);
				break;
			case 3: // south
				bb = new AxisAlignedBB(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.33F);
				break;
			case 4: // west
				bb = new AxisAlignedBB(0.66F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
				break;
			case 5: // east
				bb = new AxisAlignedBB(0.0F, 0.0F, 0.0F, 0.33F, 1.0F, 1.0F);
				break;

			}

        return bb;
    }
// ###########################################################3

 

and not criying about it, and i think is bether this way

  • Author

I think you missed the point.

 

getSelectedBoundingBox() seems to be defining the collision bounding box - not the hitbox around the block

 

getCollisionBoundingBox() is defining the hitbox - trace the code into Forge and you can clearly see that this is the case.

 

Try returning null or NULL_AABB from getCollisionBoundingBox()  (which you should be able to do to make a non-solid block, i.e. a plant) and Forge will crash because it is using this value to render, not to check the collision.

 

I'm quite sure these two methods are swapped/misnamed.

 

This also leads into the question why there are 3 methods needing a AxisAlignedBB?!?

1) getBoundingBox()

2) getSelectedBoundingBox()

3) getCollisionBoundingBox()

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.