Posted July 29, 201312 yr 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?
July 31, 201312 yr short answer, you cant make bounding box that have different xSize and zSize how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
July 31, 201312 yr /** * 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.
July 31, 201312 yr Author short answer, you cant make bounding box that have different xSize and zSize I know the door spawns itself in two seperate blocks. Could it be possible to shrink it to 2x1x1 (two long, one wide, one tall) and spawn the two blocks together? Edit: Oh yeah, duh, the bed does that.
July 31, 201312 yr no that the thing, the door itself is 2 block, not 1 if you really need a 2x1x1 hitbox make a fake block that is "attached" to your primary how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
July 31, 201312 yr Author How do you attach a block to another block? Do you just set the block in front of it to be an invisible block? Edit: never mind, going through the code for the bed now. They map the two blocks together apparently
July 31, 201312 yr 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-
July 31, 201312 yr Author 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 Alright thanks!
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.