You could look at EnderZoo's Fallen Knight for an example of this. It looks like it spawns a mount for the Fallen Knight on the first update (onLivingUpdate).
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this,
EntityGreek.class, 1.0D, true));
this.tasks.addTask(3, new EntityAIAttackOnCollide(this,
EntityZombie.class, 1.0D, true));
this.tasks.addTask(4, new EntityAIAttackOnCollide(this,
EntitySkeleton.class, 1.0D, true));
this.tasks.addTask(5, new EntityAIAttackOnCollide(this,
EntitySpider.class, 1.0D, true));
this.tasks.addTask(6, new EntityAIAttackOnCollide(this,
EntityCreeper.class, 1.0D, true));
this.tasks.addTask(7, new EntityAIAttackOnCollide(this,
EntityCaveSpider.class, 1.0D, true));
this.tasks.addTask(8, new EntityAIAttackOnCollide(this,
EntitySilverfish.class, 1.0D, true));
this.tasks.addTask(10, new EntityAIBreakDoor(this));
this.tasks.addTask(11, new EntityAIWander(this, 1.0D));
this.tasks.addTask(12, new EntityAIWatchClosest(this,
EntityPlayer.class, 6.0F));
this.tasks.addTask(13, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this,
EntityGreek.class, 0, true));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this,
EntityZombie.class, 0, true));
this.targetTasks.addTask(4, new EntityAINearestAttackableTarget(this,
EntitySkeleton.class, 0, true));
this.targetTasks.addTask(5, new EntityAINearestAttackableTarget(this,
EntityCreeper.class, 0, true));
this.targetTasks.addTask(6, new EntityAINearestAttackableTarget(this,
EntitySpider.class, 0, true));
this.targetTasks.addTask(7, new EntityAINearestAttackableTarget(this,
EntityCaveSpider.class, 0, true));
this.targetTasks.addTask(8, new EntityAINearestAttackableTarget(this,
EntitySilverfish.class, 0, true));
EntityHorse mount = null;
if (true) {
mount = new EntityHorse(worldObj);
mount.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F);
mount.onSpawnWithEgg((IEntityLivingData) null);
//NB: don;t check for entity collisions as we know the knight will collide
}
}
You have to also spawn the Horse into the world. world.spawnEntityIntoWorld(horse). I believe so. I haven't tested it but this is what I think the problem is.
I think Fir3will may have meant the link I gave you. You missed this part.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this,
EntityGreek.class, 1.0D, true));
this.tasks.addTask(3, new EntityAIAttackOnCollide(this,
EntityZombie.class, 1.0D, true));
this.tasks.addTask(4, new EntityAIAttackOnCollide(this,
EntitySkeleton.class, 1.0D, true));
this.tasks.addTask(5, new EntityAIAttackOnCollide(this,
EntitySpider.class, 1.0D, true));
this.tasks.addTask(6, new EntityAIAttackOnCollide(this,
EntityCreeper.class, 1.0D, true));
this.tasks.addTask(7, new EntityAIAttackOnCollide(this,
EntityCaveSpider.class, 1.0D, true));
this.tasks.addTask(8, new EntityAIAttackOnCollide(this,
EntitySilverfish.class, 1.0D, true));
this.tasks.addTask(10, new EntityAIBreakDoor(this));
this.tasks.addTask(11, new EntityAIWander(this, 1.0D));
this.tasks.addTask(12, new EntityAIWatchClosest(this,
EntityPlayer.class, 6.0F));
this.tasks.addTask(13, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this,
EntityGreek.class, 0, true));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this,
EntityZombie.class, 0, true));
this.targetTasks.addTask(4, new EntityAINearestAttackableTarget(this,
EntitySkeleton.class, 0, true));
this.targetTasks.addTask(5, new EntityAINearestAttackableTarget(this,
EntityCreeper.class, 0, true));
this.targetTasks.addTask(6, new EntityAINearestAttackableTarget(this,
EntitySpider.class, 0, true));
this.targetTasks.addTask(7, new EntityAINearestAttackableTarget(this,
EntityCaveSpider.class, 0, true));
this.targetTasks.addTask(8, new EntityAINearestAttackableTarget(this,
EntitySilverfish.class, 0, true));
EntityHorse mount = null;
if (true) {
mount = new EntityHorse(worldObj);
mount.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F);
mount.onSpawnWithEgg((IEntityLivingData) null);
//NB: don;t check for entity collisions as we know the knight will collide
}
if (mount != null) {
setCanPickUpLoot(false);
worldObj.spawnEntityInWorld(mount);
mountEntity(mount);
}
Random#nextInt(int) returns a value between 0 (inclusive) and the argument (exclusive).
If you pass it 3, the highest value it will return is 2. This means that the condition chance == 3 && type == 3 in onLivingUpdate will never be true.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I have been working on a roman and I want to make it spawn on a horse. I looked through the documentation and the APIs and found nothing.
Regards
Thomas
You could look at EnderZoo's Fallen Knight for an example of this. It looks like it spawns a mount for the Fallen Knight on the first update (onLivingUpdate).
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Hey Choonster!!! Thanks for your help! You got me on the right track...One problem, it doesn't spawn on a horse!
package percyjackson;
import com.steampunk.percyjackson.Percyjackson;
import java.util.List;
import java.util.Random;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIBreakDoor;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITasks;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.entity.monster.EntityCaveSpider;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntitySilverfish;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.world.World;
public class EntityRoman
extends EntityMob
{
protected boolean isAIEnabled()
{
return true;
}
private boolean firstUpdate = true;
private boolean isMounted = false;
private boolean spawned = false;
private EntityLivingBase lastAttackTarget = null;
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
getEntityAttribute(SharedMonsterAttributes.maxHealth)
.setBaseValue(50.0D);
getEntityAttribute(SharedMonsterAttributes.followRange)
.setBaseValue(50.0D);
getEntityAttribute(SharedMonsterAttributes.knockbackResistance)
.setBaseValue(0.25D);
getEntityAttribute(SharedMonsterAttributes.movementSpeed)
.setBaseValue(0.35D);
getEntityAttribute(SharedMonsterAttributes.attackDamage)
.setBaseValue(4.0D);
}
public EntityRoman(World par1World)
{
super(par1World);
this.getNavigator().setAvoidsWater(true);
boolean flag = getNavigator().getCanBreakDoors();
this.getNavigator().setBreakDoors(true);
this.getNavigator().setEnterDoors(true);
this.getNavigator().setCanSwim(true);
this.getNavigator().getPathSearchRange();
this.clearAITasks();
this.isImmuneToFire = true;
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this,
EntityGreek.class, 1.0D, true));
this.tasks.addTask(3, new EntityAIAttackOnCollide(this,
EntityZombie.class, 1.0D, true));
this.tasks.addTask(4, new EntityAIAttackOnCollide(this,
EntitySkeleton.class, 1.0D, true));
this.tasks.addTask(5, new EntityAIAttackOnCollide(this,
EntitySpider.class, 1.0D, true));
this.tasks.addTask(6, new EntityAIAttackOnCollide(this,
EntityCreeper.class, 1.0D, true));
this.tasks.addTask(7, new EntityAIAttackOnCollide(this,
EntityCaveSpider.class, 1.0D, true));
this.tasks.addTask(8, new EntityAIAttackOnCollide(this,
EntitySilverfish.class, 1.0D, true));
this.tasks.addTask(10, new EntityAIBreakDoor(this));
this.tasks.addTask(11, new EntityAIWander(this, 1.0D));
this.tasks.addTask(12, new EntityAIWatchClosest(this,
EntityPlayer.class, 6.0F));
this.tasks.addTask(13, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this,
EntityGreek.class, 0, true));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this,
EntityZombie.class, 0, true));
this.targetTasks.addTask(4, new EntityAINearestAttackableTarget(this,
EntitySkeleton.class, 0, true));
this.targetTasks.addTask(5, new EntityAINearestAttackableTarget(this,
EntityCreeper.class, 0, true));
this.targetTasks.addTask(6, new EntityAINearestAttackableTarget(this,
EntitySpider.class, 0, true));
this.targetTasks.addTask(7, new EntityAINearestAttackableTarget(this,
EntityCaveSpider.class, 0, true));
this.targetTasks.addTask(8, new EntityAINearestAttackableTarget(this,
EntitySilverfish.class, 0, true));
}
protected void clearAITasks()
{
this.tasks.taskEntries.clear();
this.targetTasks.taskEntries.clear();
}
protected Item getDropItem()
{
Random d = new Random();
int chance = d.nextInt(3);
int type = d.nextInt(3);
Item weap = null;
if(type == 0 && chance == 0){
weap = Percyjackson.Gladius;
}
return weap;
}
private void spawnMount() {
if (ridingEntity != null || !spawned) {
return;
}
EntityHorse mount = null;
if (true) {
mount = new EntityHorse(worldObj);
mount.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F);
mount.onSpawnWithEgg((IEntityLivingData) null);
//NB: don;t check for entity collisions as we know the knight will collide
}
}
private boolean isRidingMount() {
return isRiding() && ridingEntity.getClass() == EntityHorse.class;
}
@Override
public void onLivingUpdate() {
super.onLivingUpdate();
Random d = new Random();
int chance = d.nextInt(3);
int type = d.nextInt(3);
if (chance == 3 && type == 3) {
spawnMount();
}
if (isRidingMount()) {
EntityLiving entLiving = ((EntityLiving) ridingEntity);
if (lastAttackTarget != getAttackTarget() || firstUpdate) {
lastAttackTarget = getAttackTarget();
}
}
firstUpdate = false;
if (isBurning() && isRidingMount()) {
ridingEntity.setFire(8);
}
}
public ItemStack getHeldItem()
{
return new ItemStack(Percyjackson.Gladius);
}
}
You have to also spawn the Horse into the world. world.spawnEntityIntoWorld(horse). I believe so. I haven't tested it but this is what I think the problem is.
Hello!
Where should I put that line?
Exactly where you see it in the link I gave you. A bit after you instantiate the constructor.
Hello!
What link?
I think Fir3will may have meant the link I gave you. You missed this part.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Now I have this, still no spawn
package percyjackson;
import com.steampunk.percyjackson.Percyjackson;
import java.util.List;
import java.util.Random;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIBreakDoor;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITasks;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.entity.monster.EntityCaveSpider;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntitySilverfish;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.world.World;
public class EntityRoman
extends EntityMob
{
protected boolean isAIEnabled()
{
return true;
}
private boolean firstUpdate = true;
private boolean isMounted = false;
private boolean spawned = false;
private EntityLivingBase lastAttackTarget = null;
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
getEntityAttribute(SharedMonsterAttributes.maxHealth)
.setBaseValue(50.0D);
getEntityAttribute(SharedMonsterAttributes.followRange)
.setBaseValue(50.0D);
getEntityAttribute(SharedMonsterAttributes.knockbackResistance)
.setBaseValue(0.25D);
getEntityAttribute(SharedMonsterAttributes.movementSpeed)
.setBaseValue(0.35D);
getEntityAttribute(SharedMonsterAttributes.attackDamage)
.setBaseValue(4.0D);
}
public EntityRoman(World par1World)
{
super(par1World);
this.getNavigator().setAvoidsWater(true);
boolean flag = getNavigator().getCanBreakDoors();
this.getNavigator().setBreakDoors(true);
this.getNavigator().setEnterDoors(true);
this.getNavigator().setCanSwim(true);
this.getNavigator().getPathSearchRange();
this.clearAITasks();
this.isImmuneToFire = true;
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this,
EntityGreek.class, 1.0D, true));
this.tasks.addTask(3, new EntityAIAttackOnCollide(this,
EntityZombie.class, 1.0D, true));
this.tasks.addTask(4, new EntityAIAttackOnCollide(this,
EntitySkeleton.class, 1.0D, true));
this.tasks.addTask(5, new EntityAIAttackOnCollide(this,
EntitySpider.class, 1.0D, true));
this.tasks.addTask(6, new EntityAIAttackOnCollide(this,
EntityCreeper.class, 1.0D, true));
this.tasks.addTask(7, new EntityAIAttackOnCollide(this,
EntityCaveSpider.class, 1.0D, true));
this.tasks.addTask(8, new EntityAIAttackOnCollide(this,
EntitySilverfish.class, 1.0D, true));
this.tasks.addTask(10, new EntityAIBreakDoor(this));
this.tasks.addTask(11, new EntityAIWander(this, 1.0D));
this.tasks.addTask(12, new EntityAIWatchClosest(this,
EntityPlayer.class, 6.0F));
this.tasks.addTask(13, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this,
EntityGreek.class, 0, true));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this,
EntityZombie.class, 0, true));
this.targetTasks.addTask(4, new EntityAINearestAttackableTarget(this,
EntitySkeleton.class, 0, true));
this.targetTasks.addTask(5, new EntityAINearestAttackableTarget(this,
EntityCreeper.class, 0, true));
this.targetTasks.addTask(6, new EntityAINearestAttackableTarget(this,
EntitySpider.class, 0, true));
this.targetTasks.addTask(7, new EntityAINearestAttackableTarget(this,
EntityCaveSpider.class, 0, true));
this.targetTasks.addTask(8, new EntityAINearestAttackableTarget(this,
EntitySilverfish.class, 0, true));
}
protected void clearAITasks()
{
this.tasks.taskEntries.clear();
this.targetTasks.taskEntries.clear();
}
protected Item getDropItem()
{
Random d = new Random();
int chance = d.nextInt(3);
int type = d.nextInt(3);
Item weap = null;
if(type == 0 && chance == 0){
weap = Percyjackson.Gladius;
}
return weap;
}
private void spawnMount() {
if (ridingEntity != null || !spawned) {
return;
}
EntityHorse mount = null;
if (true) {
mount = new EntityHorse(worldObj);
mount.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F);
mount.onSpawnWithEgg((IEntityLivingData) null);
//NB: don;t check for entity collisions as we know the knight will collide
}
if (mount != null) {
setCanPickUpLoot(false);
worldObj.spawnEntityInWorld(mount);
mountEntity(mount);
}
}
private boolean isRidingMount() {
return isRiding() && ridingEntity.getClass() == EntityHorse.class;
}
@Override
public void onLivingUpdate() {
super.onLivingUpdate();
Random d = new Random();
int chance = d.nextInt(3);
int type = d.nextInt(3);
if (chance == 3 && type == 3) {
spawnMount();
}
if (isRidingMount()) {
EntityLiving entLiving = ((EntityLiving) ridingEntity);
if (lastAttackTarget != getAttackTarget() || firstUpdate) {
lastAttackTarget = getAttackTarget();
}
}
firstUpdate = false;
if (isBurning() && isRidingMount()) {
ridingEntity.setFire(8);
}
}
public ItemStack getHeldItem()
{
return new ItemStack(Percyjackson.Gladius);
}
}
Random#nextInt(int) returns a value between 0 (inclusive) and the argument (exclusive).
If you pass it 3, the highest value it will return is 2. This means that the condition chance == 3 && type == 3 in onLivingUpdate will never be true.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I changed the 3's to 4's and still no spawn
bump