The Meaning of Life, the Universe, and Everything.
Location:
Watching You
Join Date:
7/9/2014
Posts:
61
Location:
Right Behind You
Minecraft:
Rippingtax
Member Details
Hello there!
I know that I asked this question before, but it didn't exactly work. I also know that its been a while but I stopped modding in like February but I just got right back into it.
OK. So my question is, why the EntityGreek spawns but only ever with a sword and not a bow. Here is my class:
public class EntityGreek extends EntityMob implements IRangedAttackMob {
protected boolean isAIEnabled() {
return true;
}
private boolean isArcher;
public EntityGreek(World par1World) {
super(par1World);
getNavigator().setAvoidsWater(true);
getNavigator().setBreakDoors(true);
getNavigator().setEnterDoors(true);
getNavigator().setCanSwim(true);
getNavigator().getPathSearchRange();
clearAITasks();
this.isImmuneToFire(); //what is this for? Did you mean to do the below line? If so, un comment it.
// this.isImmuneToFire = true;
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(3, new EntityAIWander(this, 1.0D));
this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
this.tasks.addTask(5, new EntityAILookIdle(this));
//Target Tasks
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityRoman.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));
isArcher = new Random().nextBoolean();
this.setCurrentItemOrArmor(0, new ItemStack(ModItems.spear));
You also have other problems in the code though.
You probably got some of this code from the skeleton. Look closely how they change combat tasks. You must clear out the old task and then add in the new task. You are just adding a task.
protected void addRandomArmor()
{
Random r = new Random();
int type = r.nextInt(2);
if(type == 0)
{
this.setCurrentItemOrArmor(0, new ItemStack(Items.iron_sword));
}
else
{
this.setCurrentItemOrArmor(0, new ItemStack(Items.bow));
}
}
public class EntityGreek extends EntityMob implements IRangedAttackMob {
protected boolean isAIEnabled() {
return true;
}
public EntityGreek(World par1World) {
super(par1World);
getNavigator().setAvoidsWater(true);
getNavigator().setBreakDoors(true);
getNavigator().setEnterDoors(true);
getNavigator().setCanSwim(true);
getNavigator().getPathSearchRange();
clearAITasks();
this.isImmuneToFire(); //what is this for? Did you mean to do the below line? If so, un comment it.
// this.isImmuneToFire = true;
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(3, new EntityAIWander(this, 1.0D));
this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
this.tasks.addTask(5, new EntityAILookIdle(this));
//Target Tasks
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityRoman.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 addRandomArmor(){
super.addRandomArmor();
Random r = new Random();
int type = r.nextInt(2);
if(type == 0){
this.setCurrentItemOrArmor(0, new ItemStack(Percyjackson.xiphos));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityLivingBase.class, 1.0D, true));
}else{
this.setCurrentItemOrArmor(0, new ItemStack(Percyjackson.greekBow));
this.tasks.addTask(2, new EntityAIArrowAttack(this, 1.0D, 20, 60, 15.0F));
}
}
Hello there!
I know that I asked this question before, but it didn't exactly work. I also know that its been a while but I stopped modding in like February but I just got right back into it.
OK. So my question is, why the EntityGreek spawns but only ever with a sword and not a bow. Here is my class:
package percyjackson;
import com.example.percyjackson.Percyjackson;
import java.util.List;
import java.util.Random;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IRangedAttackMob;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIArrowAttack;
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.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.world.World;
public class EntityGreek extends EntityMob implements IRangedAttackMob {
protected boolean isAIEnabled() {
return true;
}
private boolean isArcher;
public EntityGreek(World par1World) {
super(par1World);
getNavigator().setAvoidsWater(true);
getNavigator().setBreakDoors(true);
getNavigator().setEnterDoors(true);
getNavigator().setCanSwim(true);
getNavigator().getPathSearchRange();
clearAITasks();
this.isImmuneToFire(); //what is this for? Did you mean to do the below line? If so, un comment it.
// this.isImmuneToFire = true;
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(3, new EntityAIWander(this, 1.0D));
this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
this.tasks.addTask(5, new EntityAILookIdle(this));
//Target Tasks
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityRoman.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));
isArcher = new Random().nextBoolean();
if(par1World != null && !par1World.isRemote)
{
this.setCombatTask();
}
}
@Override
protected void applyEntityAttributes(){
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(50.0D);
this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(50.0D);
this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(0.65D);
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.35D);
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(4.0D);
}
protected void clearAITasks(){
tasks.taskEntries.clear();
targetTasks.taskEntries.clear();
}
@Override
public void attackEntityWithRangedAttack(EntityLivingBase var1, float var2) {
// TODO Auto-generated method stub
}
public void setCombatTask(){
if(isArcher)
{
this.tasks.addTask(2, new EntityAIArrowAttack(this, 1.0D, 20, 60, 15.0F));
}
else
{
this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityLivingBase.class, 1.0D, true));
}
}
}
You have to set what weapon the mob is holding.
Something like this;
this.setCurrentItemOrArmor(0, new ItemStack(ModItems.spear));
You also have other problems in the code though.
You probably got some of this code from the skeleton. Look closely how they change combat tasks. You must clear out the old task and then add in the new task. You are just adding a task.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
Please don't make duplicate threads. And please look around before asking for help.
protected void addRandomArmor()
{ Random r = new Random(); int type = r.nextInt(2); if(type == 0) { this.setCurrentItemOrArmor(0, new ItemStack(Items.iron_sword)); }
else { this.setCurrentItemOrArmor(0, new ItemStack(Items.bow)); } }
I'm really sorry to be such a noob, but now the greek spawns with no weapon...Here is my class:
package percyjackson;
import com.steampunk.percyjackson.Percyjackson;
import java.util.List;
import java.util.Random;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IRangedAttackMob;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIArrowAttack;
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.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.world.World;
public class EntityGreek extends EntityMob implements IRangedAttackMob {
protected boolean isAIEnabled() {
return true;
}
public EntityGreek(World par1World) {
super(par1World);
getNavigator().setAvoidsWater(true);
getNavigator().setBreakDoors(true);
getNavigator().setEnterDoors(true);
getNavigator().setCanSwim(true);
getNavigator().getPathSearchRange();
clearAITasks();
this.isImmuneToFire(); //what is this for? Did you mean to do the below line? If so, un comment it.
// this.isImmuneToFire = true;
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(3, new EntityAIWander(this, 1.0D));
this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
this.tasks.addTask(5, new EntityAILookIdle(this));
//Target Tasks
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityRoman.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 addRandomArmor(){
super.addRandomArmor();
Random r = new Random();
int type = r.nextInt(2);
if(type == 0){
this.setCurrentItemOrArmor(0, new ItemStack(Percyjackson.xiphos));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityLivingBase.class, 1.0D, true));
}else{
this.setCurrentItemOrArmor(0, new ItemStack(Percyjackson.greekBow));
this.tasks.addTask(2, new EntityAIArrowAttack(this, 1.0D, 20, 60, 15.0F));
}
}
@Override
protected void applyEntityAttributes(){
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(50.0D);
this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(50.0D);
this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(0.25D);
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.35D);
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(4.0D);
}
protected void clearAITasks(){
tasks.taskEntries.clear();
targetTasks.taskEntries.clear();
}
@Override
public void attackEntityWithRangedAttack(EntityLivingBase var1, float var2) {
// TODO Auto-generated method stub
}
}
What am I doing wrong?