MC Modding
Please register and join the community!

[Answered] Override Damage to Player

MC Modding :: Help :: Help

View previous topic View next topic Go down

[Answered] Override Damage to Player

Post by TheCodeNewbie on Wed Oct 26, 2011 9:12 am

Hi, I have a block which makes all entities go on fire when they collide with it, except entity player. The code's like this:
Code:

public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity)
   
    {
        if (!(entity instanceof EntityPlayerSP))
        {
            entity.fire = 300;
        }
It works fine until you build a pillar 2 blocks high(of the block I'm making) and run into it. The screen turns into stone as if you were inside a wall. So I'm assuming that I can fix it by overriding the inWall damage to the player when he's colliding with the block....but I don't know how to do that, so if someone could help me I would appreciate it ^^


Last edited by TheCodeNewbie on Sun Oct 30, 2011 7:52 am; edited 3 times in total

TheCodeNewbie
Member

Posts : 6
Join date : 2011-10-25

View user profile

Back to top Go down

Re: [Answered] Override Damage to Player

Post by Strengthowns on Wed Oct 26, 2011 9:19 am

Why not just make it an instanceof EntityPlayer?
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

Re: [Answered] Override Damage to Player

Post by TheCodeNewbie on Wed Oct 26, 2011 10:57 am

how would I do that?

TheCodeNewbie
Member

Posts : 6
Join date : 2011-10-25

View user profile

Back to top Go down

Re: [Answered] Override Damage to Player

Post by groxmapper on Wed Oct 26, 2011 10:54 pm

TheCodeNewbie wrote:how would I do that?

Code:
if(entity instanceof EntityPlayer)
{
 return;
}else
{
      entity.fire = 300;
}

Also it isn't in-wall damage it's because you prolly forgot to tell it the block is not rendered normally (or you edited something else, post your whole code for the block please.)
avatar
groxmapper
Member

Posts : 27
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [Answered] Override Damage to Player

Post by TheCodeNewbie on Fri Oct 28, 2011 8:24 am

Oh wait I figured it out, I was having a derp moment with this in my code:
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);
    }

TheCodeNewbie
Member

Posts : 6
Join date : 2011-10-25

View user profile

Back to top Go down

Re: [Answered] Override Damage to Player

Post by TheCodeNewbie on Fri Oct 28, 2011 8:45 am

Wait getting rid of that didn't help, here's the code for my block
Blockburner.java:
Code:

package net.minecraft.src;

import java.util.Random;

public class Blockburner extends Block
{
    public Blockburner(int i, int j)
    {
        super(i, j, Material.wood);     
    }
    public int idDropped(int i, Random random)
    {
      return mod_burner.burner.blockID;
    }
    public int quantityDropped(Random random)
    {
            return 1;
    }
    public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity)
   
    {
        if(entity instanceof EntityPlayer)
        {
            return;
        }else
        {
            entity.fire = 300;
        }
    }
}
mod_burner.java:
Code:

package net.minecraft.src;

public class mod_burner extends BaseMod
{
  public static Block burner = new Blockburner(190, 0).setHardness(1.0F).setResistance(5F).setLightValue(0.2F).setBlockName("burner");
 
  public String Version()
  {
      return "1.8.1";
  }
 
  public mod_burner()
  {
      ModLoader.RegisterBlock(burner);
      burner.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/CreatureBurner.png");
      ModLoader.AddName(burner, "Block of Burning Flames");
      ModLoader.AddRecipe(new ItemStack(burner, 8), new Object[] {
      "###", "#@#", "###", Character.valueOf('#'), Block.netherrack, Character.valueOf('@'), Item.bucketLava
      });
    }
}

TheCodeNewbie
Member

Posts : 6
Join date : 2011-10-25

View user profile

Back to top Go down

Re: [Answered] Override Damage to Player

Post by Strengthowns on Fri Oct 28, 2011 9:57 am

Don't just say it didn't work, what's the error text?
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

Re: [Answered] Override Damage to Player

Post by TheCodeNewbie on Sun Oct 30, 2011 7:03 am

*sigh* It didn't fix my problem in the first post. I still don't know how to stop my character from getting damaged when I run into my block if it is stacked 2 high.

TheCodeNewbie
Member

Posts : 6
Join date : 2011-10-25

View user profile

Back to top Go down

Re: [Answered] Override Damage to Player

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


MC Modding :: Help :: Help

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