Jump to content

Collision Bounding Box


ninjapancakes87
 Share

Recommended Posts

So I've been working on a mod for a while, and it adds a new block, a cannon.  The block is 2x1x2, or two wide, two long and one high.  In my constructor I called this.setBlockBounds(minX,minY,minZ,maxX,maxY,maxZ).  However, this doesnt change the collision bounding box, only the outline of the box when you select it.  I had a look at BlockDoor, BlockWall, BlockFence, but copying and modifying their methods doesnt seem to be doing anything for me.  Does anybody know how to properly go about this?

Link to comment
Share on other sites

    /**

    * For some reason, the bounds actually have to be SMALLER (as I interpret the code) for the entity to hit it.

    * The parameters aren't quite what I would expect them to be.

    */

    public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)

    {

    float f = 0.0125f;

        return AxisAlignedBB.getAABBPool().getAABB((double)(((float)par2) + f),  (double)par3, (double)(((float)par4) + f),

          (double)((float)(par2 + 1) - f), (double)((float)(par3 + 1)), (double)((float)(par4 + 1) - f));

    }

 

 

This works for me. I have a block called lava foam. It detects when you hit the block and bounces you back

from whence you came. This routine sets the bounds of the block a little inside the actual block itself, so that

mc detects when an entity actually enters the block, and thus triggers

public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)

properly. It's strange, and you would think it would work the other way around, but this is what works...

Basically, the args are minx, miny, minz, maxx, maxy, maxz, but all are set INSIDE the actual block.

In this case I only care about x/z collisions, and leave y alone as the full block bounds.

 

 

Odds are good I've been programming since before you were born. Yeah. I'm OLD school.

Link to comment
Share on other sites

well if i was doing it (and by that i mean it might not be the best way) id make the 2nd block another kind of block with a special bounding box, and that block could never break or at least it would also break the "base" of the cannon/ the other part

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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

 Share



×
×
  • Create New...

Important Information

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