setup shoeBot to do basic harvesting

This commit is contained in:
Rseifert 2012-07-22 21:24:06 -04:00
parent 728095f8ba
commit 965e482e13

View file

@ -2,74 +2,46 @@ package net.minecraft.src.eui.robotics;
import java.util.List; import java.util.List;
import net.minecraft.src.*; import net.minecraft.src.*;
import net.minecraft.src.universalelectricity.Vector3;
public class EntityShoeBot extends EntityRobot { public class EntityShoeBot extends EntityRobot {
EntityItem targetItem = null; EntityItem targetItem = null;
public EntityShoeBot(World par1World) { public EntityShoeBot(World par1World) {
super(par1World); super(par1World);
this.setSize(0.6F, 0.5F);
this.moveSpeed = 0.23F; this.moveSpeed = 0.23F;
// this.tasks.addTask(1, new EntityAIWander(this, this.moveSpeed));
this.texture = "/mobs/char.png"; this.texture = "/mobs/char.png";
} }
public float getBlockPathWeight(int par1, int par2, int par3)
{
return 0.5F + this.worldObj.getLightBrightness(par1, par2, par3);
}
@Override @Override
public void onEntityUpdate() public void botUpdate()
{ {
super.onEntityUpdate(); super.botUpdate();
ModLoader.getMinecraftInstance().thePlayer.addChatMessage("CC");
if(targetItem == null) if(hasTask)
{ {
targetItem = findClosestItem(this.posX, this.posY, this.posZ,30); ModLoader.getMinecraftInstance().thePlayer.addChatMessage("resuming task");
} if(this.currentTask == this.getTaskType() && this.taskLocation != null)
else {
{ boolean harDone = harvest(this.taskLocation);
if(!targetItem.isEntityAlive()) if(harDone)
{ {
targetItem = null; clearTask();
} }
} }
if(targetItem != null) else
{ {
clearTask();
PathEntity PathToItem = this.worldObj.getPathEntityToEntity(this, targetItem, 30, true, false, false, true); }
if(hasPath()){
this.setPathToEntity(PathToItem); }
this.moveSpeed = 1.0F; else
if(targetItem.getDistanceSq(this.posX,this.posY,this.posZ) < 1.5) {
{ //requestTask
targetItem.setDead(); }
targetItem = null;
}
}
else
{
this.moveSpeed = 0.23F;
}
}
}
public EntityItem findClosestItem(double par1, double par3, double par5, double par7)
{
double var9 = -1.0D;
EntityItem var11 = null;
List itemList = worldObj.getEntitiesWithinAABB(EntityItem.class, this.boundingBox.expand(par7, 4.0D, par7));
for (int var12 = 0; var12 < itemList.size(); ++var12)
{
EntityItem var13 = (EntityItem)itemList.get(var12);
double var14 = var13.getDistanceSq(par1, par3, par5);
if ((par7 < 0.0D || var14 < par7 * par7) && (var9 == -1.0D || var14 < var9))
{
var9 = var14;
var11 = var13;
}
}
return var11;
} }
@Override @Override
public int getMaxHealth() { public int getMaxHealth() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -80,5 +52,8 @@ public class EntityShoeBot extends EntityRobot {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return "BlockEater"; return "BlockEater";
} }
public String getTaskType() {
return "harvest";
}
} }