Posted April 5, 201312 yr Hi all. After successfully implementing the 6 textured block, I decided to try the bounding boxes again. I'm reading the Block class, method by method. To be able to continue my reading and understanding of the class, I must understand these methods: /** * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list * if they intersect the mask.) Parameters: World, X, Y, Z, mask, list, colliding entity */ public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB mask, List list, Entity collidingEntity) { AxisAlignedBB aabb = this.getCollisionBoundingBoxFromPool(world, x, y, z); if (aabb != null && mask.intersectsWith(aabb)) { list.add(aabb); } } @SideOnly(Side.CLIENT) /** * Returns the bounding box of the wired rectangular prism to render. */ public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) { return AxisAlignedBB.getAABBPool().getAABB(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ); } /** * Returns a bounding box from the pool of bounding boxes (this means this box can change * after the pool has been cleared to be reused) */ public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { return AxisAlignedBB.getAABBPool().getAABB(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ); } Please, anyone kind enough to explain those methods to me? Pretty please? WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons
April 5, 201312 yr Author Thanks for replying! Let me see if I understand something: Do I ever need to override those methods? If I ever need a block that is not just a standard 1x1x1 block. Let's say I need a 2x2x2 block for some reason. Would I have to write another implementation of those methods? I ask because I'm still not sure when those methods are invoked and for what purpose. In that case of the 2x2x2 block, could I just change the values of block.maxX, block.maxY, block.maxZ instead of overriding any of those 3 methods to make my bigger block? In a second hypothetical scenario, Imagine that for some reason I need a block with a complex shape (for example, imagine the shape we use to create an iron golem. Let's say for this question's sake I need to have a block shaped like that). Then, I think just changing block.maxX, block.maxY, block.maxZ wouldn't be enough. So, in this case, I'd have to override those methods. Is that what those methods are for? Or I didn't understand a thing...? WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons
April 5, 201312 yr Author Hi all. I just tested the first case I suggested above in a simplified manner. I added a line this.maxX += 1 to the constructor: public class TwoBlock extends Block { public TwoBlock () { super(TwoBlockID, Material.rock); this.maxX += 1; } } I correctly get a block that's 2x1x1, with it's enlargement portion being at x + 1 relative to the point where I place it. But, I can only collide with the x, y, z portion of the block. I can pass through the x + 1, y, z portion of the block, the enlargement portion. I cross it unimpeded when I move along the Y or Z axes, and I get some sort of partial collision when I move along the X axis, i.e. when I walk inside the enlargement portion towards the normal portion. If I do this, I get pushed back a little bit when I reach the normal portion. How would I build this block so I would collide normally with it? I'm gessing I'd have to use those methods I asked about earlier? Thanks for any help! WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons
April 5, 201312 yr Author Sorry to do this, but I'm stuck. Anyone?? WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons
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.