MC Modding
Please register and join the community!

[1.8.1] Advanced Block

View previous topic View next topic Go down

[1.8.1] Advanced Block

Post by Strengthowns on Wed Oct 05, 2011 10:52 am

Advanced Block

Spoiler:
Booster Block

1. Add this to your BlockNamehere:
Code:
slipperiness = 1.5F;
so it would fit in here:
Code:
    public BlockNamehere(int i, int j)
    {
        super(i, j, Material.ground);
      slipperiness = 1.5F;
    }

Bouncy Block

1. Add this to your BlockNamehere:
Code:
   public void onEntityWalking(World world, int x, int y, int z, Entity entity)
    {
            entity.motionY += 2.0;
    }
so it would go here:
Code:
    public int idDropped(int i, Random random)
    {
      return mod_Namehere.Namehere.blockID;
    }
   public void onEntityWalking(World world, int x, int y, int z, Entity entity)
    {
            entity.motionY += 2.0;
    }
    public int quantityDropped(Random random)
    {
            return 1;
    }
}

Change the 2 to whatever you want, 5 will shoot you sky high!

Damage/heal on contact
1. Put this in your BlockNamehere:
Code:
   public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
    {
        float f = 0.0625F;
        return AxisAlignedBB.getBoundingBoxFromPool((float)i + f, j, (float)k + f, (float)(i + 1) - f, (float)(j + 1) - f, (float)(k + 1) - f);
    }
    public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k)
    {
        float f = 0.0625F;
        return AxisAlignedBB.getBoundingBoxFromPool((float)i + f, j, (float)k + f, (float)(i + 1) - f, j + 1, (float)(k + 1) - f);
    }
   public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity)
    {
        entity.attackEntityFrom(null, 4);
    }
So it would fit in here:
Code:
    public int quantityDropped(Random random)
    {
            return 1;
    }
   public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
    {
        float f = 0.0625F;
        return AxisAlignedBB.getBoundingBoxFromPool((float)i + f, j, (float)k + f, (float)(i + 1) - f, (float)(j + 1) - f, (float)(k + 1) - f);
    }
    public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k)
    {
        float f = 0.0625F;
        return AxisAlignedBB.getBoundingBoxFromPool((float)i + f, j, (float)k + f, (float)(i + 1) - f, j + 1, (float)(k + 1) - f);
    }
   public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity)
    {
        entity.attackEntityFrom(DamageSource.causeThrownDamage(entity, entity), 4);
    }
}

2. The 4 at the bottom is how many half-hearts of damage it does when you walk into it.

3. If you want it to heal you on contact, then change it to something like this:
Code:
entity.attackEntityFrom(null, -4);

4. The only downside to the heal block is the player still makes the hurt sounds...
avatar
Strengthowns
Admin

Posts : 79
Join date : 2011-06-14
Location : Right here!

View user profile http://www.mcmodding.4umer.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum