Jump to content

Recommended Posts

Posted

I'm having a problem with my mob where once its tamed it works fine, but when I shut down the game for a day then come back, it is no longer acting as if its tamed even though it doesn't deal damage. So by default its suppose to be hostile, but when you tame it, its no longer hostile and isn't suppose to attack anyone or anything, this works like it should, but the problem i stated above then come into play where after a day of not running the game, it will target you like its not tamed, but won't do damage as if it is. Also the other thing that goes hand in hand with this issue, is that since this is a chicken, i want it to lay something only when its tamed. But as with the targeting it will stop laying the item. Does anyone have any idea why this is?

 

Heres my code:

 

package mods.mochickens.mobs;

import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.client.Minecraft;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.EnchantmentThorns;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIFollowParent;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;

public class EntityBlueChicken extends EntityTameable {
public boolean field_70885_d = false;
public float field_70886_e = 0.0F;
public float destPos = 0.0F;
public float field_70884_g;
public float field_70888_h;
public float field_70889_i = 1.0F;

/** The time until the next egg is spawned. */
public int timeUntilNextEgg;

public EntityBlueChicken(World par1World) {
	super(par1World);
	this.setSize(0.3F, 0.7F);
	float f = 0.25F;
	this.tasks.addTask(0, new EntityAISwimming(this));
	this.tasks.addTask(2, new EntityAIMate(this, 1.0D));
	this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D));
	this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
	this.tasks.addTask(6, new EntityAIWatchClosest(this,
			EntityPlayer.class, 6.0F));
	this.tasks.addTask(7, new EntityAILookIdle(this));
	if (!this.isTamed()) {
	this.tasks.addTask(2, new EntityAIAttackOnCollide(this,
			EntityPlayer.class, 1.0D, false));
	this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this,
			EntityPlayer.class, 0, true));
	this.timeUntilNextEgg = -1;
	this.setTamed(false);
	} else {
		this.tasks.addTask(3, new EntityAITempt(this, 1.0D,
				Block.blockDiamond.blockID, false));
		this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
	}
}

/**
 * Returns true if the newer Entity AI code should be run
 */
public boolean isAIEnabled() {
	return true;
}

protected void applyEntityAttributes() {
	super.applyEntityAttributes();
	this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.setAttribute(4.0D);
	this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
			.setAttribute(0.25D);
}

public boolean attackEntityAsMob(Entity par1Entity) {
	if (!this.isTamed()) {
		EntityPlayer entityplayer = this.worldObj
				.getClosestVulnerablePlayerToEntity(this, 16.0D);
		// f = damage delt 2.0D = 1 heart
		float f = (float) 5.0D;
		int i = 0;

		if (entityplayer instanceof EntityLivingBase) {
			f += EnchantmentHelper.getEnchantmentModifierLiving(this,
					(EntityLivingBase) entityplayer);
			i += EnchantmentHelper.getKnockbackModifier(this,
					(EntityLivingBase) entityplayer);
			entityplayer.addPotionEffect(new PotionEffect(
					Potion.blindness.id, 200, 1));
			entityplayer.addPotionEffect(new PotionEffect(
					Potion.moveSlowdown.id, 200, 2));
		}

		boolean flag = par1Entity.attackEntityFrom(
				DamageSource.causeMobDamage(this), f);

		if (flag) {
			if (i > 0) {
				entityplayer.addVelocity(
						(double) (-MathHelper.sin(this.rotationYaw
								* (float) Math.PI / 180.0F)
								* (float) i * 0.5F),
						0.1D,
						(double) (MathHelper.cos(this.rotationYaw
								* (float) Math.PI / 180.0F)
								* (float) i * 0.5F));
				this.motionX *= 0.6D;
				this.motionZ *= 0.6D;
			}

			int j = EnchantmentHelper.getFireAspectModifier(this);

			if (j > 0) {
				entityplayer.setFire(j * 4);
			}

			if (entityplayer instanceof EntityLivingBase) {
				EnchantmentThorns.func_92096_a(this,
						(EntityLivingBase) entityplayer, this.rand);
			}
		}

		return flag;
	} else {
		return false;
	}
}

/**
 * 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.
 */
public void onLivingUpdate() {
	super.onLivingUpdate();
	this.field_70888_h = this.field_70886_e;
	this.field_70884_g = this.destPos;
	this.destPos = (float) ((double) this.destPos + (double) (this.onGround ? -1
			: 4) * 0.3D);

	if (this.destPos < 0.0F) {
		this.destPos = 0.0F;
	}

	if (this.destPos > 1.0F) {
		this.destPos = 1.0F;
	}

	if (!this.onGround && this.field_70889_i < 1.0F) {
		this.field_70889_i = 1.0F;
	}

	this.field_70889_i = (float) ((double) this.field_70889_i * 0.9D);

	if (!this.onGround && this.motionY < 0.0D) {
		this.motionY *= 0.6D;
	}

	this.field_70886_e += this.field_70889_i * 2.0F;

	if (!this.isChild() && !this.worldObj.isRemote
			&& --this.timeUntilNextEgg == 0) {
		this.playSound(
				"mob.chicken.plop",
				1.0F,
				(this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
		this.dropItem(Item.diamond.itemID, 1);
		this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
	}
}

/**
 * Called when the mob is falling. Calculates and applies fall damage.
 */
protected void fall(float par1) {
}

/**
 * Returns the sound this mob makes while it's alive.
 */
protected String getLivingSound() {
	return "mob.chicken.say";
}

/**
 * Returns the sound this mob makes when it is hurt.
 */
protected String getHurtSound() {
	return "mob.chicken.hurt";
}

/**
 * Returns the sound this mob makes on death.
 */
protected String getDeathSound() {
	return "mob.chicken.hurt";
}

/**
 * Plays step sound at given x, y, z for the entity
 */
protected void playStepSound(int par1, int par2, int par3, int par4) {
	this.playSound("mob.chicken.step", 0.15F, 1.0F);
}

/**
 * Returns the item ID for the item the mob drops on death.
 */
protected int getDropItemId() {
	return Item.feather.itemID;
}

/**
 * Drop 0-2 items of this living's type. @param par1 - Whether this entity
 * has recently been hit by a player. @param par2 - Level of Looting used to
 * kill this mob.
 */
protected void dropFewItems(boolean par1, int par2) {
	int j = this.rand.nextInt(3) + this.rand.nextInt(1 + par2);

	for (int k = 0; k < j; ++k) {
		this.dropItem(Item.diamond.itemID, 1);
	}

	if (this.isBurning()) {
		this.dropItem(Item.chickenCooked.itemID, 1);
	} else {
		this.dropItem(Item.chickenRaw.itemID, 1);
	}
}

/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow,
 * gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer par1EntityPlayer) {
	ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
	if (!this.isTamed()) {
		if (itemstack != null && itemstack.itemID == Item.diamond.itemID) {
			if (!par1EntityPlayer.capabilities.isCreativeMode) {
				--itemstack.stackSize;
			}

			if (itemstack.stackSize <= 0) {
				par1EntityPlayer.inventory.setInventorySlotContents(
						par1EntityPlayer.inventory.currentItem,
						(ItemStack) null);
			}

			if (!this.worldObj.isRemote) {
				if (this.rand.nextInt(3) == 0) {
					this.setTamed(true);
					this.setPathToEntity((PathEntity) null);
					this.setAttackTarget((EntityLivingBase) null);
					this.setTarget(null);
					this.setOwner(par1EntityPlayer.getCommandSenderName());
					this.playTameEffect(true);
					this.worldObj.setEntityState(this, (byte) 7);
					this.tasks.removeTask(new EntityAIAttackOnCollide(this,
							EntityPlayer.class, 1.0D, false));
					this.targetTasks
							.removeTask(new EntityAINearestAttackableTarget(
									this, EntityPlayer.class, 0, true));
					this.tasks.addTask(3, new EntityAITempt(this, 1.0D,
							Block.blockDiamond.blockID, false));
					this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
				} else {
					this.playTameEffect(false);
					this.worldObj.setEntityState(this, (byte) 6);
				}
			}

			return true;
		}
	}

	return super.interact(par1EntityPlayer);
}

/**
 * This function is used when two same-species animals in 'love mode' breed
 * to generate the new baby animal.
 */
public EntityBlueChicken spawnBabyAnimal(EntityAgeable par1EntityAgeable) {
	EntityBlueChicken entitybluechicken = new EntityBlueChicken(
			this.worldObj);
	String s = this.getOwnerName();

	if (s != null && s.trim().length() > 0) {
		entitybluechicken.setOwner(s);
		entitybluechicken.setTamed(true);
	}

	return entitybluechicken;
}

/**
 * Checks if the parameter is an item which this animal can be fed to breed
 * it (wheat, carrots or seeds depending on the animal type)
 */
public boolean isBreedingItem(ItemStack par1ItemStack) {
	return par1ItemStack != null
			&& par1ItemStack.itemID == Item.diamond.itemID;
}

public EntityAgeable createChild(EntityAgeable par1EntityAgeable) {
	return this.spawnBabyAnimal(par1EntityAgeable);
}
}

 

Posted

but even if the owner isnt anywhere i dont want it chasing any other players. thats where the problem is, i dont know what i need to change to stop it from chasing other players.

Posted

What debugging steps have you taken? Have you checked that you are really removing the AI for finding the nearest player? Are you sure that the chicken is still tamed when you restart the world? How about during the constructor stage, is the chicken 'tamed' while it is loading from the constructor, or does the tamed status only kick in after that stage?

 

That's my bet: the chicken's constructor is called first, at which point it hasn't loaded the value of 'isTamed' from NBT, so you add the AI for attacking the nearest player, then the NBT loads and it's set to tamed and loses the ability to do damage, but retains its AI.

 

What I'd do is override the setTamed method and put all the code changing the AI in there, then use that method when loading from NBT (which is done in the super, since you're not saving anything extra), so you'll have to override that method as well to call your setTamed if it's not already set up that way.

Posted

ok, well i looked through the readEntityNBT method and changed the check in the constructor from !isTamed() to if (this.getOwner() == null).

 

now the last thing id like to get working is that it will only be tempted by its owner. I've looked at everything about tempting that i could find and the only way i could figure out is to remake the EntityAITempt class and modify it, the problem is that I dont know where the ShouldExicute() method is called and used and I can't call on entity.getOwner() to check if the tempting player is its owner or not. are there any suggestions for what i should to to get around this? or where to look?

Posted

upon further testing, i found out that what i did actually didnt work, it stopped the mob from chasing players, but it set it to that with mobs that werent tamed. im just lost with this. could someone show me some sort of an example so i can see what it should look like?

Posted

You can't set this particular AI in the constructor and expect it to work - there is no owner at this point as the entity has not yet been read from NBT. Do you understand that? You can do it in the constructor when constructing a NEW entity after the world is loaded by passing in a valid EntityPlayer object, but otherwise you need to access the methods when reading from NBT.

 

Here's what I use for summoned creatures, but you have to understand what I wrote in my previous post about setting AI from within a method such as setOwner or setTamed for it to work:

@Override
public final void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
String s = par1NBTTagCompound.getString("Owner");

if (s.length() > 0)
{
	this.setOwner(s);
	this.setTamed(true);
}

this.aiSit.setSitting(par1NBTTagCompound.getBoolean("Sitting"));
this.setSitting(par1NBTTagCompound.getBoolean("Sitting"));
this.setLifespan(par1NBTTagCompound.getInteger("Lifespan"));
}
// Here's an example of how I set the AI whenever the owner changes - so this automatically updates the
// AI even for the constructor, as I call this method rather than setting things manually
/**
* Sets owner's name and adds AI to follow owner
*/
public final void setOwner(String par1Str)
{
this.dataWatcher.updateObject(17, par1Str);
if (par1Str.length() > 0)
	this.tasks.addTask(4, new EntityAIFollowSummoner(this, this.getOwner(), 1.0D, 10.0F, 2.0F));
}

Posted

lets see if im understand this right, if i am and i'm in fact doing it right, then its still not working, otherwise, a more in depth explanation might help?

 

so what your saying is, i need to override the readEntityFromNBT and call on another method if the section that sets the mob being tamed to set the tasks the way they need to be set?

 

eg.

 

public final void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
	super.readEntityFromNBT(par1NBTTagCompound);
	String s = par1NBTTagCompound.getString("Owner");

	if (s.length() > 0) {
		this.setTamed(true);
		this.setOwner(s);
		this.setTasks();
	}
}


public void setTasks() {
	if (this.isTamed()) {
		this.worldObj.setEntityState(this, (byte) 7);
		this.tasks.removeTask(new EntityAIAttackOnCollide(this,
				EntityPlayer.class, 1.0D, false));
		this.targetTasks.removeTask(new EntityAINearestAttackableTarget(
				this, EntityPlayer.class, 0, true));
		this.tasks.addTask(3, new EntityAITempt(this, 1.0D,
				Block.blockDiamond.blockID, false));
		this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
	}
}

Posted

Basically, yes, but it all depends on what else is going on in your Entity methods. Please post your entire Entity code, as well as explain what specifically isn't working. Is the Entity still attacking players? Still following random players? The more specific you are, the easier it is to pinpoint the problem.

 

I would recommend printing some information to the console when reading from NBT so you can see if there is an owner, what the owner's name is, and any other information you think might be relevant. This will help you troubleshoot.

Posted

here is my most recent code:

package mods.mochickens.mobs;

import java.util.logging.Logger;

import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.client.Minecraft;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.EnchantmentThorns;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIFollowParent;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;

public class EntityBlueChicken extends EntityTameable {
public boolean field_70885_d = false;
public float field_70886_e = 0.0F;
public float destPos = 0.0F;
public float field_70884_g;
public float field_70888_h;
public float field_70889_i = 1.0F;

/** The time until the next egg is spawned. */
public int timeUntilNextEgg;

public EntityBlueChicken(World par1World) {
	super(par1World);
	this.setSize(0.3F, 0.7F);
	float f = 0.25F;
	this.tasks.addTask(0, new EntityAISwimming(this));
	this.tasks.addTask(2, new EntityAIMate(this, 1.0D));
	this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D));
	this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
	this.tasks.addTask(6, new EntityAIWatchClosest(this,
			EntityPlayer.class, 6.0F));
	this.tasks.addTask(7, new EntityAILookIdle(this));
	this.tasks.addTask(2, new EntityAIAttackOnCollide(this,
			EntityPlayer.class, 1.0D, false));
	this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this,
			EntityPlayer.class, 0, true));
	this.timeUntilNextEgg = -1;
	this.setTamed(false);
}

/**
 * Returns true if the newer Entity AI code should be run
 */
public boolean isAIEnabled() {
	return true;
}

protected void applyEntityAttributes() {
	super.applyEntityAttributes();
	this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.setAttribute(4.0D);
	this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
			.setAttribute(0.25D);
}

@Override
public final void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
	super.readEntityFromNBT(par1NBTTagCompound);
	String s = par1NBTTagCompound.getString("Owner");
	MinecraftServer.getServer().getLogAgent().logInfo("reading NBT");

	if (s.length() > 0) {
		MinecraftServer.getServer().getLogAgent().logInfo("setting tamed");
		this.setTamed(true);
		this.setOwner(s);
	}
}

    @Override
public void setTamed(boolean par1)
    {
        byte b0 = this.dataWatcher.getWatchableObjectByte(16);
        MinecraftServer.getServer().getLogAgent().logInfo("in setTamed");

        if (par1)
        {
            this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 4)));
			MinecraftServer.getServer().getLogAgent().logInfo("set tasks");
        }
        else
        {
            this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -5)));
            this.worldObj.setEntityState(this, (byte) 7);
			this.tasks.removeTask(new EntityAIAttackOnCollide(this,
					EntityPlayer.class, 1.0D, false));
			this.targetTasks.removeTask(new EntityAINearestAttackableTarget(
					this, EntityPlayer.class, 0, true));
			this.tasks.addTask(3, new EntityAITempt(this, 1.0D,
					Block.blockDiamond.blockID, false));
			this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
            MinecraftServer.getServer().getLogAgent().logInfo("not tasks");
        }
    }

public boolean attackEntityAsMob(Entity par1Entity) {
	if (!this.isTamed()) {
		EntityPlayer entityplayer = this.worldObj
				.getClosestVulnerablePlayerToEntity(this, 16.0D);
		// f = damage delt 2.0D = 1 heart
		float f = (float) 5.0D;
		int i = 0;

		if (entityplayer instanceof EntityLivingBase) {
			f += EnchantmentHelper.getEnchantmentModifierLiving(this,
					(EntityLivingBase) entityplayer);
			i += EnchantmentHelper.getKnockbackModifier(this,
					(EntityLivingBase) entityplayer);
			entityplayer.addPotionEffect(new PotionEffect(
					Potion.blindness.id, 200, 1));
			entityplayer.addPotionEffect(new PotionEffect(
					Potion.moveSlowdown.id, 200, 2));
		}

		boolean flag = par1Entity.attackEntityFrom(
				DamageSource.causeMobDamage(this), f);

		if (flag) {
			if (i > 0) {
				entityplayer.addVelocity(
						(double) (-MathHelper.sin(this.rotationYaw
								* (float) Math.PI / 180.0F)
								* (float) i * 0.5F),
						0.1D,
						(double) (MathHelper.cos(this.rotationYaw
								* (float) Math.PI / 180.0F)
								* (float) i * 0.5F));
				this.motionX *= 0.6D;
				this.motionZ *= 0.6D;
			}

			int j = EnchantmentHelper.getFireAspectModifier(this);

			if (j > 0) {
				entityplayer.setFire(j * 4);
			}

			if (entityplayer instanceof EntityLivingBase) {
				EnchantmentThorns.func_92096_a(this,
						(EntityLivingBase) entityplayer, this.rand);
			}
		}

		return flag;
	} else {
		return false;
	}
}

/**
 * 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.
 */
public void onLivingUpdate() {
	super.onLivingUpdate();
	this.field_70888_h = this.field_70886_e;
	this.field_70884_g = this.destPos;
	this.destPos = (float) ((double) this.destPos + (double) (this.onGround ? -1
			: 4) * 0.3D);

	if (this.destPos < 0.0F) {
		this.destPos = 0.0F;
	}

	if (this.destPos > 1.0F) {
		this.destPos = 1.0F;
	}

	if (!this.onGround && this.field_70889_i < 1.0F) {
		this.field_70889_i = 1.0F;
	}

	this.field_70889_i = (float) ((double) this.field_70889_i * 0.9D);

	if (!this.onGround && this.motionY < 0.0D) {
		this.motionY *= 0.6D;
	}

	this.field_70886_e += this.field_70889_i * 2.0F;

	if (!this.isChild() && !this.worldObj.isRemote
			&& --this.timeUntilNextEgg == 0) {
		this.playSound(
				"mob.chicken.plop",
				1.0F,
				(this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
		this.dropItem(Item.diamond.itemID, 1);
		this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
	}
}

/**
 * Called when the mob is falling. Calculates and applies fall damage.
 */
protected void fall(float par1) {
}

/**
 * Returns the sound this mob makes while it's alive.
 */
protected String getLivingSound() {
	return "mob.chicken.say";
}

/**
 * Returns the sound this mob makes when it is hurt.
 */
protected String getHurtSound() {
	return "mob.chicken.hurt";
}

/**
 * Returns the sound this mob makes on death.
 */
protected String getDeathSound() {
	return "mob.chicken.hurt";
}

/**
 * Plays step sound at given x, y, z for the entity
 */
protected void playStepSound(int par1, int par2, int par3, int par4) {
	this.playSound("mob.chicken.step", 0.15F, 1.0F);
}

/**
 * Returns the item ID for the item the mob drops on death.
 */
protected int getDropItemId() {
	return Item.feather.itemID;
}

/**
 * Drop 0-2 items of this living's type. @param par1 - Whether this entity
 * has recently been hit by a player. @param par2 - Level of Looting used to
 * kill this mob.
 */
protected void dropFewItems(boolean par1, int par2) {
	int j = this.rand.nextInt(3) + this.rand.nextInt(1 + par2);

	for (int k = 0; k < j; ++k) {
		this.dropItem(Item.diamond.itemID, 1);
	}

	if (this.isBurning()) {
		this.dropItem(Item.chickenCooked.itemID, 1);
	} else {
		this.dropItem(Item.chickenRaw.itemID, 1);
	}
}

/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow,
 * gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer par1EntityPlayer) {
	ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
	if (!this.isTamed()) {
		if (itemstack != null && itemstack.itemID == Item.diamond.itemID) {
			if (!par1EntityPlayer.capabilities.isCreativeMode) {
				--itemstack.stackSize;
			}

			if (itemstack.stackSize <= 0) {
				par1EntityPlayer.inventory.setInventorySlotContents(
						par1EntityPlayer.inventory.currentItem,
						(ItemStack) null);
			}

			if (!this.worldObj.isRemote) {
				if (this.rand.nextInt(3) == 0) {
					this.setTamed(true);
					this.setPathToEntity((PathEntity) null);
					this.setAttackTarget((EntityLivingBase) null);
					this.setTarget(null);
					this.setOwner(par1EntityPlayer.getCommandSenderName());
					this.playTameEffect(true);
					this.worldObj.setEntityState(this, (byte) 7);
					this.tasks.removeTask(new EntityAIAttackOnCollide(this,
							EntityPlayer.class, 1.0D, false));
					this.targetTasks
							.removeTask(new EntityAINearestAttackableTarget(
									this, EntityPlayer.class, 0, true));
					this.tasks.addTask(3, new EntityAITempt(this, 1.0D,
							Block.blockDiamond.blockID, false));
					this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
				} else {
					this.playTameEffect(false);
					this.worldObj.setEntityState(this, (byte) 6);
				}
			}

			return true;
		}
	}

	return super.interact(par1EntityPlayer);
}

/**
 * This function is used when two same-species animals in 'love mode' breed
 * to generate the new baby animal.
 */
public EntityBlueChicken spawnBabyAnimal(EntityAgeable par1EntityAgeable) {
	EntityBlueChicken entitybluechicken = new EntityBlueChicken(
			this.worldObj);
	String s = this.getOwnerName();

	if (s != null && s.trim().length() > 0) {
		entitybluechicken.setOwner(s);
		entitybluechicken.setTamed(true);
	}

	return entitybluechicken;
}

/**
 * Checks if the parameter is an item which this animal can be fed to breed
 * it (wheat, carrots or seeds depending on the animal type)
 */
public boolean isBreedingItem(ItemStack par1ItemStack) {
	if (this.isTamed()) {
		return par1ItemStack != null
				&& par1ItemStack.itemID == Item.diamond.itemID;
	} else {
		return false;
	}
}

public EntityAgeable createChild(EntityAgeable par1EntityAgeable) {
	return this.spawnBabyAnimal(par1EntityAgeable);
}
}

 

here are the world load logs:

 

 

2013-11-06 20:37:20 [iNFO] [ForgeModLoader] Loading dimension 0 (test) (net.minecraft.server.integrated.IntegratedServer@391e1c57)

2013-11-06 20:37:20 [iNFO] [ForgeModLoader] Loading dimension 1 (test) (net.minecraft.server.integrated.IntegratedServer@391e1c57)

2013-11-06 20:37:20 [iNFO] [ForgeModLoader] Loading dimension -1 (test) (net.minecraft.server.integrated.IntegratedServer@391e1c57)

2013-11-06 20:37:20 [iNFO] [Minecraft-Server] Preparing start region for level 0

2013-11-06 20:37:20 [iNFO] [Minecraft-Server] in setTamed

2013-11-06 20:37:20 [iNFO] [Minecraft-Server] not tasks

2013-11-06 20:37:20 [iNFO] [Minecraft-Server] reading NBT

2013-11-06 20:37:20 [iNFO] [Minecraft-Server] in setTamed

2013-11-06 20:37:20 [iNFO] [Minecraft-Server] not tasks

2013-11-06 20:37:20 [iNFO] [Minecraft-Server] reading NBT

2013-11-06 20:37:21 [iNFO] [Minecraft-Server] in setTamed

2013-11-06 20:37:21 [iNFO] [Minecraft-Server] not tasks

2013-11-06 20:37:21 [iNFO] [Minecraft-Server] in setTamed

2013-11-06 20:37:21 [iNFO] [Minecraft-Server] set tasks

2013-11-06 20:37:21 [iNFO] [Minecraft-Server] reading NBT

2013-11-06 20:37:21 [iNFO] [Minecraft-Server] setting tamed

2013-11-06 20:37:21 [iNFO] [Minecraft-Server] in setTamed

2013-11-06 20:37:21 [iNFO] [Minecraft-Server] set tasks

2013-11-06 20:37:21 [iNFO] [Minecraft-Server] Preparing spawn area: 60%

2013-11-06 20:37:22 [iNFO] [sTDOUT] loading single player

2013-11-06 20:37:22 [iNFO] [Minecraft-Server] Player68[/127.0.0.1:0] logged in with entity id 243 at (0.8735968462123416, 68.0, 658.8247769157815)

2013-11-06 20:37:22 [iNFO] [Minecraft-Server] Player68 joined the game

2013-11-06 20:37:22 [iNFO] [sTDOUT] Setting up custom skins

2013-11-06 20:37:22 [iNFO] [Minecraft-Server] in setTamed

2013-11-06 20:37:22 [iNFO] [Minecraft-Server] not tasks

2013-11-06 20:37:23 [iNFO] [Minecraft-Server] in setTamed

2013-11-06 20:37:23 [iNFO] [Minecraft-Server] not tasks

2013-11-06 20:37:23 [iNFO] [Minecraft-Server] in setTamed

2013-11-06 20:37:23 [iNFO] [Minecraft-Server] not tasks

2013-11-06 20:38:08 [iNFO] [Minecraft-Server] in setTamed

2013-11-06 20:38:08 [iNFO] [Minecraft-Server] not tasks

2013-11-06 20:38:08 [iNFO] [Minecraft-Server] in setTamed

2013-11-06 20:38:08 [iNFO] [Minecraft-Server] not tasks

2013-11-06 20:38:17 [iNFO] [Minecraft-Server] Saving and pausing game...

2013-11-06 20:38:17 [iNFO] [Minecraft-Server] Saving chunks for level 'test'/Overworld

2013-11-06 20:38:17 [iNFO] [Minecraft-Server] Saving chunks for level 'test'/Nether

2013-11-06 20:38:17 [iNFO] [Minecraft-Server] Saving chunks for level 'test'/The End

2013-11-06 20:38:18 [iNFO] [Minecraft-Server] Stopping server

2013-11-06 20:38:18 [iNFO] [Minecraft-Server] Saving players

2013-11-06 20:38:18 [iNFO] [Minecraft-Server] Player68 left the game

2013-11-06 20:38:18 [iNFO] [Minecraft-Server] Saving worlds

2013-11-06 20:38:18 [iNFO] [Minecraft-Server] Saving chunks for level 'test'/Overworld

2013-11-06 20:38:18 [iNFO] [Minecraft-Server] Saving chunks for level 'test'/Nether

2013-11-06 20:38:18 [iNFO] [Minecraft-Server] Saving chunks for level 'test'/The End

2013-11-06 20:38:18 [iNFO] [ForgeModLoader] Unloading dimension 0

2013-11-06 20:38:18 [iNFO] [ForgeModLoader] Unloading dimension -1

2013-11-06 20:38:18 [iNFO] [ForgeModLoader] Unloading dimension 1

2013-11-06 20:38:19 [iNFO] [Minecraft-Client] Stopping!

 

 

 

ive tried putting the tasks in either part of the if in the setTamed and neither of the changes seemed to work, the chicken still chased other players without dealing damage after restarting the world.

Posted

Ok, so the EntityAIAttackOnCollide task is successfully removed, but the target task EntityAINearestAttackableTarget is not being removed even though it is in the same block of code. I don't know why that would be, but I can think of two options for you:

 

1. Look through the removeTask code and see if there is something that would prevent your target task from being removed successfully, then adjust your code to fix it.

 

2. Use 'this.targetTasks.clear()' instead, as I'm guessing you don't have any other target tasks anyway.

 

If none of that works, then I'd suggest figuring out what all of those field_7088x fields are for; perhaps the boolean type field is the same as isTamed and it's always set to false? Why on earth would you name fields like that in a class you built yourself anyway?

Posted

public boolean attackEntityAsMob(Entity par1Entity) {
	if (!this.isTamed()) {
		EntityPlayer entityplayer = this.worldObj
				.getClosestVulnerablePlayerToEntity(this, 16.0D);
		// f = damage delt 2.0D = 1 heart
		float f = (float) 5.0D;
		int i = 0;

		if (entityplayer instanceof EntityLivingBase) {
			f += EnchantmentHelper.getEnchantmentModifierLiving(this,
					(EntityLivingBase) entityplayer);
			i += EnchantmentHelper.getKnockbackModifier(this,
					(EntityLivingBase) entityplayer);
			entityplayer.addPotionEffect(new PotionEffect(
					Potion.blindness.id, 200, 1));
			entityplayer.addPotionEffect(new PotionEffect(
					Potion.moveSlowdown.id, 200, 2));
		}

		boolean flag = par1Entity.attackEntityFrom(
				DamageSource.causeMobDamage(this), f);

		if (flag) {
			if (i > 0) {
				entityplayer.addVelocity(
						(double) (-MathHelper.sin(this.rotationYaw
								* (float) Math.PI / 180.0F)
								* (float) i * 0.5F),
						0.1D,
						(double) (MathHelper.cos(this.rotationYaw
								* (float) Math.PI / 180.0F)
								* (float) i * 0.5F));
				this.motionX *= 0.6D;
				this.motionZ *= 0.6D;
			}

			int j = EnchantmentHelper.getFireAspectModifier(this);

			if (j > 0) {
				entityplayer.setFire(j * 4);
			}

			if (entityplayer instanceof EntityLivingBase) {
				EnchantmentThorns.func_92096_a(this,
						(EntityLivingBase) entityplayer, this.rand);
			}
		}

		return flag;
	} else {
		return false;
	}
}

 

the check on if the mob is tamed or not causes it not to do damage if its tamed.

 

targetTasks does not have a clear() method.

 

the field_7088x is not something i coded, i told the code from vanilla files that did essentially what i wanted, i just had to modify it to what i need it to do, which is whats causing the trouble.

 

the method removeTask() is shown as this:

public void removeTask(EntityAIBase par1EntityAIBase)
    {
        Iterator iterator = this.taskEntries.iterator();

        while (iterator.hasNext())
        {
            EntityAITaskEntry entityaitaskentry = (EntityAITaskEntry)iterator.next();
            EntityAIBase entityaibase1 = entityaitaskentry.action;

            if (entityaibase1 == par1EntityAIBase)
            {
                if (this.executingTaskEntries.contains(entityaitaskentry))
                {
                    entityaibase1.resetTask();
                    this.executingTaskEntries.remove(entityaitaskentry);
                }

                iterator.remove();
            }
        }
    }

this does not show much much in which i could change in my code.

 

I added a couple lines to the logging process to make it easier to see where it is coming from and here is what im getting.

 

updated code:

package mods.mochickens.mobs;

import java.util.logging.Logger;

import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.client.Minecraft;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.EnchantmentThorns;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIFollowParent;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;

public class EntityBlueChicken extends EntityTameable {
public boolean field_70885_d = false;
public float field_70886_e = 0.0F;
public float destPos = 0.0F;
public float field_70884_g;
public float field_70888_h;
public float field_70889_i = 1.0F;

/** The time until the next egg is spawned. */
public int timeUntilNextEgg;

public EntityBlueChicken(World par1World) {
	super(par1World);
	this.setSize(0.3F, 0.7F);
	float f = 0.25F;
	this.tasks.addTask(0, new EntityAISwimming(this));
	this.tasks.addTask(2, new EntityAIMate(this, 1.0D));
	this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D));
	this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
	this.tasks.addTask(6, new EntityAIWatchClosest(this,
			EntityPlayer.class, 6.0F));
	this.tasks.addTask(7, new EntityAILookIdle(this));
	this.tasks.addTask(2, new EntityAIAttackOnCollide(this,
			EntityPlayer.class, 1.0D, false));
	this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this,
			EntityPlayer.class, 0, true));
	this.timeUntilNextEgg = -1;
	MinecraftServer.getServer().getLogAgent().logInfo("entity init");
	this.setTamed(false);
}

/**
 * Returns true if the newer Entity AI code should be run
 */
public boolean isAIEnabled() {
	return true;
}

protected void applyEntityAttributes() {
	super.applyEntityAttributes();
	this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.setAttribute(4.0D);
	this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
			.setAttribute(0.25D);
}

@Override
public final void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
	super.readEntityFromNBT(par1NBTTagCompound);
	String s = par1NBTTagCompound.getString("Owner");
	MinecraftServer.getServer().getLogAgent().logInfo("reading NBT");

	if (s.length() > 0) {
		MinecraftServer.getServer().getLogAgent().logInfo("setting tamed");
		MinecraftServer.getServer().getLogAgent().logInfo("Owner: " + s);
		this.setTamed(true);
		this.setOwner(s);
	}
}

    @Override
public void setTamed(boolean par1)
    {
        byte b0 = this.dataWatcher.getWatchableObjectByte(16);
        MinecraftServer.getServer().getLogAgent().logInfo("in setTamed");

        if (par1)
        {
            this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 4)));
            this.worldObj.setEntityState(this, (byte) 7);
			this.tasks.removeTask(new EntityAIAttackOnCollide(this,
					EntityPlayer.class, 1.0D, false));
			this.targetTasks.removeTask(new EntityAINearestAttackableTarget(
					this, EntityPlayer.class, 0, true));
			this.tasks.addTask(3, new EntityAITempt(this, 1.0D,
					Block.blockDiamond.blockID, false));
			this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
			MinecraftServer.getServer().getLogAgent().logInfo("set tasks");
        }
        else
        {
            this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -5)));
            MinecraftServer.getServer().getLogAgent().logInfo("not tasks");
        }
    }

public boolean attackEntityAsMob(Entity par1Entity) {
	if (!this.isTamed()) {
		EntityPlayer entityplayer = this.worldObj
				.getClosestVulnerablePlayerToEntity(this, 16.0D);
		// f = damage delt 2.0D = 1 heart
		float f = (float) 5.0D;
		int i = 0;

		if (entityplayer instanceof EntityLivingBase) {
			f += EnchantmentHelper.getEnchantmentModifierLiving(this,
					(EntityLivingBase) entityplayer);
			i += EnchantmentHelper.getKnockbackModifier(this,
					(EntityLivingBase) entityplayer);
			entityplayer.addPotionEffect(new PotionEffect(
					Potion.blindness.id, 200, 1));
			entityplayer.addPotionEffect(new PotionEffect(
					Potion.moveSlowdown.id, 200, 2));
		}

		boolean flag = par1Entity.attackEntityFrom(
				DamageSource.causeMobDamage(this), f);

		if (flag) {
			if (i > 0) {
				entityplayer.addVelocity(
						(double) (-MathHelper.sin(this.rotationYaw
								* (float) Math.PI / 180.0F)
								* (float) i * 0.5F),
						0.1D,
						(double) (MathHelper.cos(this.rotationYaw
								* (float) Math.PI / 180.0F)
								* (float) i * 0.5F));
				this.motionX *= 0.6D;
				this.motionZ *= 0.6D;
			}

			int j = EnchantmentHelper.getFireAspectModifier(this);

			if (j > 0) {
				entityplayer.setFire(j * 4);
			}

			if (entityplayer instanceof EntityLivingBase) {
				EnchantmentThorns.func_92096_a(this,
						(EntityLivingBase) entityplayer, this.rand);
			}
		}

		return flag;
	} else {
		return false;
	}
}

/**
 * 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.
 */
public void onLivingUpdate() {
	super.onLivingUpdate();
	this.field_70888_h = this.field_70886_e;
	this.field_70884_g = this.destPos;
	this.destPos = (float) ((double) this.destPos + (double) (this.onGround ? -1
			: 4) * 0.3D);

	if (this.destPos < 0.0F) {
		this.destPos = 0.0F;
	}

	if (this.destPos > 1.0F) {
		this.destPos = 1.0F;
	}

	if (!this.onGround && this.field_70889_i < 1.0F) {
		this.field_70889_i = 1.0F;
	}

	this.field_70889_i = (float) ((double) this.field_70889_i * 0.9D);

	if (!this.onGround && this.motionY < 0.0D) {
		this.motionY *= 0.6D;
	}

	this.field_70886_e += this.field_70889_i * 2.0F;

	if (!this.isChild() && !this.worldObj.isRemote
			&& --this.timeUntilNextEgg == 0) {
		this.playSound(
				"mob.chicken.plop",
				1.0F,
				(this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
		this.dropItem(Item.diamond.itemID, 1);
		this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
	}
}

/**
 * Called when the mob is falling. Calculates and applies fall damage.
 */
protected void fall(float par1) {
}

/**
 * Returns the sound this mob makes while it's alive.
 */
protected String getLivingSound() {
	return "mob.chicken.say";
}

/**
 * Returns the sound this mob makes when it is hurt.
 */
protected String getHurtSound() {
	return "mob.chicken.hurt";
}

/**
 * Returns the sound this mob makes on death.
 */
protected String getDeathSound() {
	return "mob.chicken.hurt";
}

/**
 * Plays step sound at given x, y, z for the entity
 */
protected void playStepSound(int par1, int par2, int par3, int par4) {
	this.playSound("mob.chicken.step", 0.15F, 1.0F);
}

/**
 * Returns the item ID for the item the mob drops on death.
 */
protected int getDropItemId() {
	return Item.feather.itemID;
}

/**
 * Drop 0-2 items of this living's type. @param par1 - Whether this entity
 * has recently been hit by a player. @param par2 - Level of Looting used to
 * kill this mob.
 */
protected void dropFewItems(boolean par1, int par2) {
	int j = this.rand.nextInt(3) + this.rand.nextInt(1 + par2);

	for (int k = 0; k < j; ++k) {
		this.dropItem(Item.diamond.itemID, 1);
	}

	if (this.isBurning()) {
		this.dropItem(Item.chickenCooked.itemID, 1);
	} else {
		this.dropItem(Item.chickenRaw.itemID, 1);
	}
}

/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow,
 * gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer par1EntityPlayer) {
	ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
	if (!this.isTamed()) {
		if (itemstack != null && itemstack.itemID == Item.diamond.itemID) {
			if (!par1EntityPlayer.capabilities.isCreativeMode) {
				--itemstack.stackSize;
			}

			if (itemstack.stackSize <= 0) {
				par1EntityPlayer.inventory.setInventorySlotContents(
						par1EntityPlayer.inventory.currentItem,
						(ItemStack) null);
			}

			if (!this.worldObj.isRemote) {
				if (this.rand.nextInt(3) == 0) {
					this.setTamed(true);
					this.setPathToEntity((PathEntity) null);
					this.setAttackTarget((EntityLivingBase) null);
					this.setTarget(null);
					this.setOwner(par1EntityPlayer.getCommandSenderName());
					this.playTameEffect(true);
					this.worldObj.setEntityState(this, (byte) 7);
					this.tasks.removeTask(new EntityAIAttackOnCollide(this,
							EntityPlayer.class, 1.0D, false));
					this.targetTasks
							.removeTask(new EntityAINearestAttackableTarget(
									this, EntityPlayer.class, 0, true));
					this.tasks.addTask(3, new EntityAITempt(this, 1.0D,
							Block.blockDiamond.blockID, false));
					this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
				} else {
					this.playTameEffect(false);
					this.worldObj.setEntityState(this, (byte) 6);
				}
			}

			return true;
		}
	}

	return super.interact(par1EntityPlayer);
}

/**
 * This function is used when two same-species animals in 'love mode' breed
 * to generate the new baby animal.
 */
public EntityBlueChicken spawnBabyAnimal(EntityAgeable par1EntityAgeable) {
	EntityBlueChicken entitybluechicken = new EntityBlueChicken(
			this.worldObj);
	String s = this.getOwnerName();

	if (s != null && s.trim().length() > 0) {
		entitybluechicken.setOwner(s);
		entitybluechicken.setTamed(true);
	}

	return entitybluechicken;
}

/**
 * Checks if the parameter is an item which this animal can be fed to breed
 * it (wheat, carrots or seeds depending on the animal type)
 */
public boolean isBreedingItem(ItemStack par1ItemStack) {
	if (this.isTamed()) {
		return par1ItemStack != null
				&& par1ItemStack.itemID == Item.diamond.itemID;
	} else {
		return false;
	}
}

public EntityAgeable createChild(EntityAgeable par1EntityAgeable) {
	return this.spawnBabyAnimal(par1EntityAgeable);
}
}

 

new logs:

 

 

2013-11-08 21:16:25 [iNFO] [ForgeModLoader] Loading dimension 0 (test) (net.minecraft.server.integrated.IntegratedServer@30d2a277)

2013-11-08 21:16:25 [iNFO] [ForgeModLoader] Loading dimension 1 (test) (net.minecraft.server.integrated.IntegratedServer@30d2a277)

2013-11-08 21:16:25 [iNFO] [ForgeModLoader] Loading dimension -1 (test) (net.minecraft.server.integrated.IntegratedServer@30d2a277)

2013-11-08 21:16:25 [iNFO] [Minecraft-Server] Preparing start region for level 0

2013-11-08 21:16:25 [iNFO] [Minecraft-Server] entity init

2013-11-08 21:16:25 [iNFO] [Minecraft-Server] in setTamed

2013-11-08 21:16:25 [iNFO] [Minecraft-Server] not tasks

2013-11-08 21:16:25 [iNFO] [Minecraft-Server] reading NBT

2013-11-08 21:16:25 [iNFO] [Minecraft-Server] entity init

2013-11-08 21:16:25 [iNFO] [Minecraft-Server] in setTamed

2013-11-08 21:16:25 [iNFO] [Minecraft-Server] not tasks

2013-11-08 21:16:25 [iNFO] [Minecraft-Server] reading NBT

2013-11-08 21:16:26 [iNFO] [Minecraft-Server] entity init

2013-11-08 21:16:26 [iNFO] [Minecraft-Server] in setTamed

2013-11-08 21:16:26 [iNFO] [Minecraft-Server] not tasks

2013-11-08 21:16:26 [iNFO] [Minecraft-Server] in setTamed

2013-11-08 21:16:26 [iNFO] [Minecraft-Server] set tasks

2013-11-08 21:16:26 [iNFO] [Minecraft-Server] reading NBT

2013-11-08 21:16:26 [iNFO] [Minecraft-Server] setting tamed

2013-11-08 21:16:26 [iNFO] [Minecraft-Server] Owner: Player699

2013-11-08 21:16:26 [iNFO] [Minecraft-Server] in setTamed

2013-11-08 21:16:26 [iNFO] [Minecraft-Server] set tasks

2013-11-08 21:16:26 [iNFO] [Minecraft-Server] Preparing spawn area: 53%

2013-11-08 21:16:27 [iNFO] [sTDOUT] loading single player

2013-11-08 21:16:27 [iNFO] [Minecraft-Server] Player767[/127.0.0.1:0] logged in with entity id 269 at (-0.2254044902455985, 67.0, 668.6191804974779)

2013-11-08 21:16:27 [iNFO] [Minecraft-Server] Player767 joined the game

2013-11-08 21:16:27 [iNFO] [sTDOUT] Setting up custom skins

2013-11-08 21:16:27 [iNFO] [Minecraft-Server] entity init

2013-11-08 21:16:27 [iNFO] [Minecraft-Server] in setTamed

2013-11-08 21:16:27 [iNFO] [Minecraft-Server] not tasks

2013-11-08 21:16:28 [iNFO] [Minecraft-Server] entity init

2013-11-08 21:16:28 [iNFO] [Minecraft-Server] in setTamed

2013-11-08 21:16:28 [iNFO] [Minecraft-Server] not tasks

2013-11-08 21:16:28 [iNFO] [Minecraft-Server] entity init

2013-11-08 21:16:28 [iNFO] [Minecraft-Server] in setTamed

2013-11-08 21:16:28 [iNFO] [Minecraft-Server] not tasks

 

 

 

from what i am seeing, it is setting up 3 more entities after the tamed one, i am wondering if there is a way to see if they are the same instance of the tamed one, or if they are different instances or it. if they are the same instance then that would explain why the targetTask doesnt seem to be getting removed.

Posted

targetTasks.taskEntries.clear() will clear all entries in targetTasks.

 

BUT, the removeTask method should work, so the problem is elsewhere. Try removing all of the oddly-named fields from your code. You really shouldn't need them for anything, since whatever they are for should be dealt with in the super class.

Posted

FINALLY!!!!

targetTasks.taskEntries.clear() was all i needed. i replaced

this.targetTasks.removeTask(newEntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); 

with the clear() and now it works! thank you so much!

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I need to know what mod is doing this crash, i mean the mod xenon is doing the crash but i want to know who mod is incompatible with xenon, but please i need to know a solution if i need to replace xenon, i cant use optifine anymore and all the other mods i tried(sodium, lithium, vulkan, etc) doesn't work, it crash the game.
    • I have been trying to solve a consistent crashing issue on my brother's computer where it will crash during the "Scanning Mod Candidates" phase of the loading process that starts when you click the play button on the Minecraft launcher. The issue seems to stem from a missing library that it mentions in the log file I provide below. I might I'm missing the bigger issue here for a smaller one but hopefully someone can find what I'm missing. Here's all of the stuff that I've been able to figure out so far: 1. It has nothing to do with mods, the crash happened with a real modpack, and even when I made a custom modpack and launched it without putting ANY mods into it (That is where the log file comes from by the way). 2. I have tried to find this class like a file in the Minecraft folders, but I've had no luck finding it (I don't think it works like that, but since I really don't understand how it works, I just figured I'd try). 3. I haven't seen anyone else have this issue before. 4. I know that my modpack (with mods) does work since I've run it on my computer, and it works fantastic. For some reason my brother's computer can't seem to run anything through curseforge. 5. This is for Minecraft version 1.20.1, Minecraft launcher version 3.4.50-2.1.3, forge 47.3.0, and curseforge app version 1.256.0.21056 6. My brother is using a Dell laptop from 6 years ago running Windows 10 (If you think more info on this would help, please ask as I do have it. I'm just choosing not to put it here for now). 7. I have reinstalled the curseforge app and installed Minecraft version 1.20.1. I have not reinstalled Minecraft or forge 47.3.0 but I didn't know if that would help. 8. I had an error code of 1 Please let me know if there is anything else that I am missing that you would like me to add to this post/add in a comment! Lastly, many thanks in advance to whoever can help! ------------- LOG FILE (latest.log) ------------- (from /Users/<NAME OF USER>/cursforge/minecraft/Instances/<THE NAME OF MY EMPTY MODPACK>/logs/latest.log) (This was made after running an empty modpack with same versions for all apps) ("[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/hxXvGGEK ------------- DEBUG.LOG (I realized that I should have put this here first after I had done all of the work on putting latest.log in) -------------------- (again, "[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/Fmh8GHYs
    • Pastebin... https://pastebin.com/Y3iZ85L5   Brand new profile, does not point to a mod as far as I can tell, my fatal message just has something about mixins. Don't know much about reading logs like this, but am genuinely stuck, please help. Java updated, pc restarted.
    • I was playing minecraft, forge 47.3.0 and 1.20.1, but when i tried to play minecraft now only crashes, i need help please. here is the crash report: https://securelogger.net/files/e6640a4f-9ed0-4acc-8d06-2e500c77aaaf.txt
  • Topics

×
×
  • Create New...

Important Information

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