Posted January 5, 201312 yr I have created some new items and i have set their bounds different then normal. For example if i made one 10 blocks long i would be able to walk through 9 of the blocks. The texture still shows though on the 10 long block. i have tryed setting public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { float var5 = 1F; return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double)((float)par2 + var5), (double)par3, (double)((float)par4 + var5), (double)((float)(par2 + 1) - var5), (double)(par3 + 1), (double)((float)(par4 + 1) - var5)); } but im still able to walk through them
January 5, 201312 yr At risk of putting my foot in my mouth, there are two problems with your method. Firstly, you're using getSelectedBoundingBoxFromPool. This method, as the name *and javadoc* imply, only affects what happens when a player puts their cursor over the block (and is client-side only, to boot). Take a look at BlockFence, that block is technically 1.5 blocks tall and has an example of what you're trying to do. In addition, I'm worried by your use of 'var5's and 'par2's and other anonymous variables -- it makes code terribly difficult to read. MCP-decompiled code looks like that only because of how the vanilla minecraft code has to be deobfuscated and decombiled. Variable names *that represent what the variable does* are much, much better -- take a look at the methods near the end of Block.java, specifically the bit after the "FORGE START" comment for an example of what I'm talking about.
January 6, 201312 yr Author public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool(2,2,2,3,3,3); } is what fence uses and it doesnt change the fact i can walk through my block no matter what i put as the min and max
January 6, 201312 yr public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool(2,2,2,3,3,3); } is what fence uses and it doesnt change the fact i can walk through my block no matter what i put as the min and max Firstly: You can rename parameters in overridden methods. getCollisionBoundingBoxFromPool(World world, int x, int y, int z) is *far* easier on the eyes than (World par1, int par2. . .). Secondly, take another look at the fence's code -- you've changed the collision box so that, instead of starting at the relevant block's x, y, and z coordinates, it starts at the (2,2,2) coordinate -- four levels deep in bedrock, not too far from the initial spawn in the x and z directions, no matter where the relevant block actually *is*. And I apologize that my knowledge of the minecraft engine is somewhat limited, but you might have problems with your block if it extends across chunks. In general, if a something needs to have a collision box larger than 1 block multiple blocks are used instead -- the top and bottom of a door are technically separate blocks, as is the arm of a piston. The fence (and fence gate) is vanilla minecraft's only block that has a collision box extending beyond it's 1x1x1 m cube.
September 21, 201312 yr I also am trying to get a block to be walk through. I looked at the vanilla blocks that are walk through, namely BlockTallGrass and it's super class, BlockPlant. Both have this: public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { return null; } When I use this on my block, I can force my player into the block by having it in a hole, but when there is an open area to the side of the block the block pushes me into the open space. Anyone know how to fix this?
September 21, 201312 yr I looked at the vanilla blocks that are walk through, namely BlockTallGrass and it's super class, BlockPlant. Both have this: public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { return null; } In addition to this, in the blocks constructor, add a call to //this.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ); this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); This allowed me to walk through a block. Let me know if this doesn't work and I can look into it more. allout58
September 21, 201312 yr What was causing my bug is that I didn't have this: @Override public boolean renderAsNormalBlock(){ return false; } Once I changed this, it worked perfectly!
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.