Jump to content

Recommended Posts

Posted

Hello, I am new here.  I am working my way through the book 'Minecraft Mod development in 24 hours' and it's pretty great but unfortunately it was written before 1.8.  I am learning a lot converting all the examples over but I have gotten a little stumped after making my own metadata block that is two full size blocks and a half height slab.  Everything looks great and places great but when I walk over the blocks it seems like it is basing the collision detection on the block I am looking at rather than the block I am standing on.  For example, if I look at a half height block I can walk onto a full height block, and if I look at a full height block I can't walk onto a half height block.

 

Any ideas?

 

Block Class:

 

  Reveal hidden contents

 

Posted
  On 3/31/2015 at 9:13 AM, herbix said:

You need to override getCollisionBoundingBox or addCollisionBoxesToList. These two is called during the collision check.

 

Thanks that works perfectly. Here is the override in case it helps anyone.

 

    @Override
    public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
    {
	float f = 1.0F;
	IBlockState iblockstate = worldIn.getBlockState(pos);
     if (iblockstate.getBlock() == this)
        {
			EnumSamBlockTypes btype = (EnumSamBlockTypes)(iblockstate.getValue(BlockType));

	        switch (btype)
	        {
		        case SAMSTONE_SLAB:
		            f = 0.5F;
		        default:
	        }

        }
     return new AxisAlignedBB((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)((float)pos.getY() + (float) f), (double)pos.getZ() + this.maxZ);
    }

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.