Jump to content

Recommended Posts

Posted

Hi there. I am programming some mod using Forge and I found one bug - when I spawn entity (pigzombie in this case) it spawns two PigZombies, one is normal (walking around etc), the 2nd one is stuck, it can't be hurt and does not move. When I leave world and come back there again it disappear. My code:

public boolean itemInteractionForEntity(ItemStack is, EntityPlayer playerEntity, EntityLivingBase targetEntity)

    {

        World world = playerEntity.worldObj;

        EntityCreature creature;

       

        if(targetEntity instanceof EntityZombie)

            creature = new EntityPigZombie(world);

        else if(targetEntity instanceof EntityCow)

            creature = new EntityMooshroom(world);

        else

            return false;

       

        Vec3 pos = targetEntity.getPosition(1.0F);

        targetEntity.setDead();

        world.playSoundEffect((double)pos.xCoord + 0.5D, (double)pos.yCoord + 0.5D, (double)pos.zCoord + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);

       

        world.spawnEntityInWorld(creature);

        creature.setPosition(pos.xCoord, pos.yCoord, pos.zCoord);

       

        is.damageItem(10, playerEntity);

       

        return true;

    }

I'm begginer with Minecraft modding. Thanks for help.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...