Jump to content

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


10paktimbits

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

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.