I have been updating my Creep Mod and I just added in new cows. They work perfectly, except they won't spawn. I know why this happens, I'm trying to spawn them in a dimension with no grass. The following facts are true:
- EntityCreepCow.java extends EntityCow.java
- My new dimension has no grass.
- I need help fast.
Here's my EntityCreepCow.java:
package net.minecraft.src;
import java.util.Random;
public class EntityCreepCow extends EntityCow
{
public EntityCreepCow(World par1World)
{
super(par1World);
texture = "/creep/mob/creep_cow.png";
setSize(0.9F, 1.3F);
getNavigator().func_48664_a(true);
tasks.addTask(0, new EntityAISwimming(this));
tasks.addTask(1, new EntityAIPanic(this, 0.38F));
tasks.addTask(2, new EntityAIMate(this, 0.2F));
tasks.addTask(3, new EntityAITempt(this, 0.25F, Item.wheat.shiftedIndex, false));
tasks.addTask(4, new EntityAIFollowParent(this, 0.25F));
tasks.addTask(5, new EntityAIWander(this, 0.2F));
tasks.addTask(6, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 6F));
tasks.addTask(7, new EntityAILookIdle(this));
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
public boolean getCanSpawnHere()
{
int i = MathHelper.floor_double(posX);
int j = MathHelper.floor_double(boundingBox.minY);
int k = MathHelper.floor_double(posZ);
return worldObj.getBlockId(i, j - 1, k) == mod_CreepDimension.creepstone.blockID && super.getCanSpawnHere();
}
public float getBlockPathWeight(int par1, int par2, int par3)
{
if (worldObj.getBlockId(par1, par2 - 1, par3) == mod_CreepDimension.creepstone.blockID)
{
return 10F;
}
else
{
return worldObj.getLightBrightness(par1, par2, par3) - 0.5F;
}
}
public int getMaxHealth()
{
return 10;
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "mob.cow";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.cowhurt";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.cowhurt";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 0.4F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return Item.leather.shiftedIndex;
}
/**
* Drop 0-2 items of this living's type
*/
protected void dropFewItems(boolean par1, int par2)
{
int i = rand.nextInt(3) + rand.nextInt(1 + par2);
for (int j = 0; j < i; j++)
{
dropItem(Item.leather.shiftedIndex, 1);
}
i = rand.nextInt(3) + 1 + rand.nextInt(1 + par2);
for (int k = 0; k < i; k++)
{
if (isBurning())
{
dropItem(mod_CreepDimension.creepCowSteak.shiftedIndex, 1);
}
else
{
dropItem(mod_CreepDimension.creepCowBeef.shiftedIndex, 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 (itemstack != null && itemstack.itemID == Item.bucketEmpty.shiftedIndex)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, new ItemStack(Item.bucketMilk));
return true;
}
else
{
return super.interact(par1EntityPlayer);
}
}
/**
* This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
*/
public EntityAnimal spawnBabyAnimal(EntityAnimal par1EntityAnimal)
{
return new EntityCreepCow(worldObj);
}
}
I tried getting it to extend this class, a modification of EntityAnimal.java, but it turned out as a humanoid and still wouldn't spawn:
EntityCreepAnimal.java:
package net.minecraft.src;
import java.util.List;
import java.util.Random;
public abstract class EntityCreepAnimal extends EntityAnimal
{
public EntityCreepAnimal(World par1World)
{
super(par1World);
}
public float getBlockPathWeight(int par1, int par2, int par3)
{
if (worldObj.getBlockId(par1, par2 - 1, par3) == mod_CreepDimension.creepstone.blockID)
{
return 10F;
}
else
{
return worldObj.getLightBrightness(par1, par2, par3) - 0.5F;
}
}
/**
* Checks if the entity's current position is a valid location to spawn this entity.
*/
public boolean getCanSpawnHere()
{
int i = MathHelper.floor_double(posX);
int j = MathHelper.floor_double(boundingBox.minY);
int k = MathHelper.floor_double(posZ);
return worldObj.getBlockId(i, j - 1, k) == mod_CreepDimension.creepstone.blockID && worldObj.getFullBlockLightValue(i, j, k) > 8 && super.getCanSpawnHere();
}
}
HELP ME!!!
Rollback Post to RevisionRollBack
The creeper was once the crowning jewel of Minecraft... Until those retarded Endermen... FIGHT FOR CREEPER RIGHTS!!! SUPPORT THE CREEP MOD!
Well unless I'm out to lunch, your getCanSpawnHere method is what you want to look at. (Forgive me, I'm not familiar with the cow classes)
Try this - purely for testing purposes only and not as a permanent solution:
public boolean getCanSpawnHere()
{
return true;
}
Now, if that works, my gut says your declaration of super.getCanSpawnHere() is the issue. What this is doing is asking the parent object if the entity can spawn. The parent is saying no, which is why you're not getting spawns.
So change it to:
public boolean getCanSpawnHere()
{
int i = MathHelper.floor_double(posX);
int j = MathHelper.floor_double(boundingBox.minY);
int k = MathHelper.floor_double(posZ);
return worldObj.getBlockId(i, j - 1, k) == mod_CreepDimension.creepstone.blockID;
}
Course, I could be totally wrong. If that doesn't work, I'll have to do some testing.
I have been updating my Creep Mod and I just added in new cows. They work perfectly, except they won't spawn. I know why this happens, I'm trying to spawn them in a dimension with no grass. The following facts are true:
- EntityCreepCow.java extends EntityCow.java
- My new dimension has no grass.
- I need help fast.
Here's my EntityCreepCow.java:
I tried getting it to extend this class, a modification of EntityAnimal.java, but it turned out as a humanoid and still wouldn't spawn:
EntityCreepAnimal.java:
HELP ME!!!
Try this - purely for testing purposes only and not as a permanent solution:
Now, if that works, my gut says your declaration of super.getCanSpawnHere() is the issue. What this is doing is asking the parent object if the entity can spawn. The parent is saying no, which is why you're not getting spawns.
So change it to:
Course, I could be totally wrong. If that doesn't work, I'll have to do some testing.
EDIT: YES! YES YES YES! THANKYOU SOOOOO MUCH!