Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello there,

 

I've made an Item wich spawns an entity but this is what happens:

 

[1] Chat message appears twice

[2] Entity is spawned twice

[3] One of the two can move and be hit, the other one just stands there and can't be damaged or anything.

 

this is the spawner code:

 

package net.minecraft.src;

 

public class ItemBlaziumOrb extends Item

{

        public ItemBlaziumOrb(int i)

        {

                        super(i);

                        maxStackSize = 1;   

        }

        public String getTextureFile()

        {

                return "/DPIndex.png";

        }

        public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)

        {

        par3EntityPlayer.addChatMessage("Ultima has been summoned, this is it.");

       

        EntityUltima entityliving = new EntityUltima(par2World);

        entityliving.setPosition(par3EntityPlayer.posX + 1, par3EntityPlayer.posY + 0, par3EntityPlayer.posZ + 0);

        par2World.spawnEntityInWorld(entityliving);

       

        par1ItemStack.stackSize--;

       

        return par1ItemStack;

        }

}

 

 

Please help, I really need this! I don't understand why Its doing it twice all the time, I've followed countless tutorials.

 

EntityUltima

 

package net.minecraft.src;

 

public class EntityUltima extends EntityMob

{

protected int burningTime;

public static int counterEntity;

    public EntityUltima(World par1World)

    {

        super(par1World);

        this.texture = "/Ultima.png";

        this.moveSpeed = 0.4F;

        this.attackStrength = 25;

        this.burningTime = 30;

        this.isImmuneToFire = true;

        this.experienceValue = 9999;

        this.getNavigator().setBreakDoors(true);

        this.tasks.addTask(0, new EntityAISwimming(this));

        this.tasks.addTask(1, new EntityAIBreakDoor(this));

        this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, this.moveSpeed, false));

        this.tasks.addTask(3, new EntityAIAttackOnCollide(this, EntityVillager.class, this.moveSpeed, true));

        this.tasks.addTask(4, new EntityAIMoveTwardsRestriction(this, this.moveSpeed));

        this.tasks.addTask(5, new EntityAIMoveThroughVillage(this, this.moveSpeed, false));

        this.tasks.addTask(6, new EntityAIWander(this, this.moveSpeed));

        this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));

        this.tasks.addTask(7, new EntityAILookIdle(this));

        this.tasks.addTask(8, new EntityAIAttackOnCollide(this, net.minecraft.src.EntityAnimal.class, moveSpeed, true));

        this.tasks.addTask(8, new EntityAIAttackOnCollide(this, net.minecraft.src.EntityMob.class, moveSpeed, true));

        this.targetTasks.addTask(9, new EntityAINearestAttackableTarget(this, net.minecraft.src.EntityAnimal.class, 16F, 0, false));

        this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));

        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 16.0F, 0, true));

        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, 16.0F, 0, false));

        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityCreeper.class, 16.0F, 0, false));

    }

 

    public int getMaxHealth()

    {

        return 200000;

    }

 

    /**

    * Returns the current armor value as determined by a call to InventoryPlayer.getTotalArmorValue

    */

    public void onLivingUpdate()

    {

        super.onLivingUpdate();

 

        int var1 = MathHelper.floor_double(this.posX);

        int var2 = MathHelper.floor_double(this.posZ);

        for (var1 = 0; var1 < 4; ++var1)

        {

            var2 = MathHelper.floor_double(this.posX + (double)((float)(var1 % 2 * 2 - 1) * 0.25F));

            int var3 = MathHelper.floor_double(this.posY);

            int var4 = MathHelper.floor_double(this.posZ + (double)((float)(var1 / 2 % 2 * 2 - 1) * 0.25F));

 

            if (this.worldObj.getBlockId(var2, var3, var4) == 0 && this.worldObj.getBiomeGenForCoords(var2, var4).getFloatTemperature() > 0.0F && Block.fire.canPlaceBlockAt(this.worldObj, var2, var3, var4))

            {

                this.worldObj.setBlockWithNotify(var2, var3, var4, Block.fire.blockID);

            }

        }

    }

    public int getTotalArmorValue()

    {

        return 8;

    }

   

 

    /**

    * Returns true if the newer Entity AI code should be run

    */

    protected boolean isAIEnabled()

    {

        return true;

    }

 

    /**

    * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons

    * use this to react to sunlight and start to burn.

 

    /**

    * Returns the sound this mob makes while it's alive.

    */

    protected String getLivingSound()

    {

        return "mob.zombie";

    }

 

    /**

    * Returns the sound this mob makes when it is hurt.

    */

    protected String getHurtSound()

    {

        return "mob.zombiehurt";

    }

 

    /**

    * Returns the sound this mob makes on death.

    */

    protected String getDeathSound()

    {

        return "mob.zombiedeath";

    }

 

    /**

    * Returns the item ID for the item the mob drops on death.

    */

    protected int getDropItemId()

    {

        return mod_banes.EdgeUltima.shiftedIndex;

    }

    protected void dropFewItems(boolean par1, int par2)

    {

        super.dropFewItems(par1, par2);

 

        if (par1 && (this.rand.nextInt(3) == 0 || this.rand.nextInt(1 + par2) > 0))

        {

            this.dropItem(mod_banes.EdgeUltima.shiftedIndex, 1);

        }

    }

    /**

    * Get this Entity's EnumCreatureAttribute

    */

    public EnumCreatureAttribute getCreatureAttribute()

    {

        return EnumCreatureAttribute.UNDEAD;

    }

public boolean canBreatheUnderwater()

    {

        return true;

    }

    public int getMaxSpawnedInChunk()

    {

        return 1;

    }

}

 

 

Hello there,

 

I've made an Item wich spawns an entity but this is what happens:

 

[1] Chat message appears twice

[2] Entity is spawned twice

[3] One of the two can move and be hit, the other one just stands there and can't be damaged or anything.

 

this is the spawner code:

 

package net.minecraft.src;

 

public class ItemBlaziumOrb extends Item

{

        public ItemBlaziumOrb(int i)

        {

                        super(i);

                        maxStackSize = 1;   

        }

        public String getTextureFile()

        {

                return "/DPIndex.png";

        }

        public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)

        {

        par3EntityPlayer.addChatMessage("Ultima has been summoned, this is it.");

       

        EntityUltima entityliving = new EntityUltima(par2World);

        entityliving.setPosition(par3EntityPlayer.posX + 1, par3EntityPlayer.posY + 0, par3EntityPlayer.posZ + 0);

        par2World.spawnEntityInWorld(entityliving);

       

        par1ItemStack.stackSize--;

       

        return par1ItemStack;

        }

}

 

 

Please help, I really need this! I don't understand why Its doing it twice all the time, I've followed countless tutorials.

 

EntityUltima

 

package net.minecraft.src;

 

public class EntityUltima extends EntityMob

{

protected int burningTime;

public static int counterEntity;

    public EntityUltima(World par1World)

    {

        super(par1World);

        this.texture = "/Ultima.png";

        this.moveSpeed = 0.4F;

        this.attackStrength = 25;

        this.burningTime = 30;

        this.isImmuneToFire = true;

        this.experienceValue = 9999;

        this.getNavigator().setBreakDoors(true);

        this.tasks.addTask(0, new EntityAISwimming(this));

        this.tasks.addTask(1, new EntityAIBreakDoor(this));

        this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, this.moveSpeed, false));

        this.tasks.addTask(3, new EntityAIAttackOnCollide(this, EntityVillager.class, this.moveSpeed, true));

        this.tasks.addTask(4, new EntityAIMoveTwardsRestriction(this, this.moveSpeed));

        this.tasks.addTask(5, new EntityAIMoveThroughVillage(this, this.moveSpeed, false));

        this.tasks.addTask(6, new EntityAIWander(this, this.moveSpeed));

        this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));

        this.tasks.addTask(7, new EntityAILookIdle(this));

        this.tasks.addTask(8, new EntityAIAttackOnCollide(this, net.minecraft.src.EntityAnimal.class, moveSpeed, true));

        this.tasks.addTask(8, new EntityAIAttackOnCollide(this, net.minecraft.src.EntityMob.class, moveSpeed, true));

        this.targetTasks.addTask(9, new EntityAINearestAttackableTarget(this, net.minecraft.src.EntityAnimal.class, 16F, 0, false));

        this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));

        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 16.0F, 0, true));

        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, 16.0F, 0, false));

        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityCreeper.class, 16.0F, 0, false));

    }

 

    public int getMaxHealth()

    {

        return 200000;

    }

 

    /**

    * Returns the current armor value as determined by a call to InventoryPlayer.getTotalArmorValue

    */

    public void onLivingUpdate()

    {

        super.onLivingUpdate();

 

        int var1 = MathHelper.floor_double(this.posX);

        int var2 = MathHelper.floor_double(this.posZ);

        for (var1 = 0; var1 < 4; ++var1)

        {

            var2 = MathHelper.floor_double(this.posX + (double)((float)(var1 % 2 * 2 - 1) * 0.25F));

            int var3 = MathHelper.floor_double(this.posY);

            int var4 = MathHelper.floor_double(this.posZ + (double)((float)(var1 / 2 % 2 * 2 - 1) * 0.25F));

 

            if (this.worldObj.getBlockId(var2, var3, var4) == 0 && this.worldObj.getBiomeGenForCoords(var2, var4).getFloatTemperature() > 0.0F && Block.fire.canPlaceBlockAt(this.worldObj, var2, var3, var4))

            {

                this.worldObj.setBlockWithNotify(var2, var3, var4, Block.fire.blockID);

            }

        }

    }

    public int getTotalArmorValue()

    {

        return 8;

    }

   

 

    /**

    * Returns true if the newer Entity AI code should be run

    */

    protected boolean isAIEnabled()

    {

        return true;

    }

 

    /**

    * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons

    * use this to react to sunlight and start to burn.

 

    /**

    * Returns the sound this mob makes while it's alive.

    */

    protected String getLivingSound()

    {

        return "mob.zombie";

    }

 

    /**

    * Returns the sound this mob makes when it is hurt.

    */

    protected String getHurtSound()

    {

        return "mob.zombiehurt";

    }

 

    /**

    * Returns the sound this mob makes on death.

    */

    protected String getDeathSound()

    {

        return "mob.zombiedeath";

    }

 

    /**

    * Returns the item ID for the item the mob drops on death.

    */

    protected int getDropItemId()

    {

        return mod_banes.EdgeUltima.shiftedIndex;

    }

    protected void dropFewItems(boolean par1, int par2)

    {

        super.dropFewItems(par1, par2);

 

        if (par1 && (this.rand.nextInt(3) == 0 || this.rand.nextInt(1 + par2) > 0))

        {

            this.dropItem(mod_banes.EdgeUltima.shiftedIndex, 1);

        }

    }

    /**

    * Get this Entity's EnumCreatureAttribute

    */

    public EnumCreatureAttribute getCreatureAttribute()

    {

        return EnumCreatureAttribute.UNDEAD;

    }

public boolean canBreatheUnderwater()

    {

        return true;

    }

    public int getMaxSpawnedInChunk()

    {

        return 1;

    }

}

 

 

 

What about adding a

if(!world.isRemote){}

around all the chat message and entity things?

Uhmm... maybe change the [uNSOLVED] in the post name to [sOLVED]? People might think it's annoying when you don't do that.

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...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.