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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

×
×
  • Create New...