Minor Robit AI enhancements

This commit is contained in:
Aidan Brady 2013-08-01 01:28:27 -04:00
parent 768f76e364
commit 773f40717c
2 changed files with 14 additions and 3 deletions

View file

@ -24,6 +24,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
@ -53,7 +54,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine
getNavigator().setAvoidsWater(true); getNavigator().setAvoidsWater(true);
tasks.addTask(1, new RobitAIFollow(this, 0.3F, 5.0F, 2.0F)); tasks.addTask(1, new RobitAIFollow(this, 1.0F, 10.0F, 2.0F));
tasks.addTask(2, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); tasks.addTask(2, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
tasks.addTask(2, new EntityAILookIdle(this)); tasks.addTask(2, new EntityAILookIdle(this));
tasks.addTask(3, new EntityAISwimming(this)); tasks.addTask(3, new EntityAISwimming(this));
@ -140,7 +141,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine
return; return;
} }
if(!(homeLocation.getTileEntity(worldObj) instanceof TileEntityChargepad)) if(!(homeLocation.getTileEntity(MinecraftServer.getServer().worldServerForDimension(homeLocation.dimensionId)) instanceof TileEntityChargepad))
{ {
drop(); drop();
setDead(); setDead();
@ -292,6 +293,12 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine
public void goHome() public void goHome()
{ {
setFollowing(false); setFollowing(false);
if(worldObj.provider.dimensionId != homeLocation.dimensionId)
{
travelToDimension(homeLocation.dimensionId);
}
setPositionAndUpdate(homeLocation.xCoord+0.5, homeLocation.yCoord+0.3, homeLocation.zCoord+0.5); setPositionAndUpdate(homeLocation.xCoord+0.5, homeLocation.yCoord+0.3, homeLocation.zCoord+0.5);
motionX = 0; motionX = 0;

View file

@ -55,6 +55,10 @@ public class RobitAIFollow extends EntityAIBase
{ {
return false; return false;
} }
else if(theRobit.worldObj.provider.dimensionId != player.worldObj.provider.dimensionId)
{
return false;
}
else if(!theRobit.getFollowing()) else if(!theRobit.getFollowing())
{ {
return false; return false;
@ -76,7 +80,7 @@ public class RobitAIFollow extends EntityAIBase
@Override @Override
public boolean continueExecuting() public boolean continueExecuting()
{ {
return !thePathfinder.noPath() && theRobit.getDistanceSqToEntity(theOwner) > (maxDist * maxDist) && theRobit.getFollowing() && theRobit.getEnergy() > 0; return !thePathfinder.noPath() && theRobit.getDistanceSqToEntity(theOwner) > (maxDist * maxDist) && theRobit.getFollowing() && theRobit.getEnergy() > 0 && theOwner.worldObj.provider.dimensionId == theRobit.worldObj.provider.dimensionId;
} }
@Override @Override