This commit is contained in:
Calclavia 2012-11-03 11:01:09 +08:00
parent 3fe2e0b919
commit d3a40a764b
2 changed files with 47 additions and 42 deletions

View file

@ -4,7 +4,7 @@ import net.minecraft.src.TileEntity;
/** /**
* An AI Task that is used by TileEntities with * An AI Task that is used by TileEntities with
* simple AI. * AI.
* *
* @author Calclavia * @author Calclavia
* *
@ -32,11 +32,15 @@ public abstract class Task
* - The amount of ticks this task * - The amount of ticks this task
* has been elapsed for. * has been elapsed for.
*/ */
protected void onDoTask() protected void doTask()
{ {
this.ticks++; this.ticks++;
} }
public void resetTask()
{
}
/** /**
* @return Whether the task should keep * @return Whether the task should keep
* executing. * executing.

View file

@ -11,14 +11,16 @@ import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
public class TileEntityCraftingArm extends TileEntityBase implements IElectricityReceiver { public class TileEntityCraftingArm extends TileEntityBase implements IElectricityReceiver
{
public enum armTasks public enum armTasks
{ {
NONE,COLLECT,MINE,PLACE,SORT,CRAFT NONE, COLLECT, MINE, PLACE, SORT, CRAFT
} }
/** /**
* Entity robotic arm to be used with this tileEntity * Entity robotic arm to be used with this
* tileEntity
*/ */
public EntityCraftingArm EntityArm = null; public EntityCraftingArm EntityArm = null;
@ -39,7 +41,7 @@ public class TileEntityCraftingArm extends TileEntityBase implements IElectricit
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
if(this.ticks % 5 == 0 && !this.isDisabled() && this.hasTask && EntityArm != null) if (this.ticks % 5 == 0 && !this.isDisabled() && this.hasTask && EntityArm != null)
{ {
this.jouleReceived -= this.wattUsed; this.jouleReceived -= this.wattUsed;
this.doWork(); this.doWork();
@ -47,7 +49,8 @@ public class TileEntityCraftingArm extends TileEntityBase implements IElectricit
} }
/** /**
* controls the robotic arm into doing a set task * controls the robotic arm into doing a set
* task
*/ */
public void doWork() public void doWork()
{ {
@ -58,60 +61,59 @@ public class TileEntityCraftingArm extends TileEntityBase implements IElectricit
* UE methods * UE methods
*/ */
@Override @Override
public void onReceive(TileEntity sender, double amps, double voltage, public void onReceive(TileEntity sender, double amps, double voltage, ForgeDirection side)
ForgeDirection side) { {
this.jouleReceived = Math.max(jouleReceived + (amps * voltage), this.jouleReceived = Math.max(jouleReceived + (amps * voltage), maxJoules);
maxJoules);
} }
@Override @Override
public double wattRequest() { public double wattRequest()
{
return maxJoules - jouleReceived; return maxJoules - jouleReceived;
} }
@Override @Override
public boolean canReceiveFromSide(ForgeDirection side) { public boolean canReceiveFromSide(ForgeDirection side)
if (side != ForgeDirection.UP) {
return true;
}
return false;
}
@Override
public void onDisable(int duration) {
// TODO Auto-generated method stub
}
@Override
public boolean isDisabled() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean canConnect(ForgeDirection side) {
if(side != ForgeDirection.UP)
{ {
return true; if (side != ForgeDirection.UP) { return true; }
}
return false; return false;
} }
@Override @Override
public double getVoltage() { public void onDisable(int duration)
{
// TODO Auto-generated method stub
}
@Override
public boolean isDisabled()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean canConnect(ForgeDirection side)
{
if (side != ForgeDirection.UP) { return true; }
return false;
}
@Override
public double getVoltage()
{
// TODO Auto-generated method stub // TODO Auto-generated method stub
return 120; return 120;
} }
/** /**
* Data * Data
*/ */
@Override @Override
public void handlePacketData(INetworkManager network, int packetType, public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
Packet250CustomPayload packet, EntityPlayer player, {
ByteArrayDataInput dataStream) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@ -120,18 +122,17 @@ public class TileEntityCraftingArm extends TileEntityBase implements IElectricit
* inventory * inventory
*/ */
@Override @Override
public int getSizeInventory() { public int getSizeInventory()
{
// TODO Auto-generated method stub // TODO Auto-generated method stub
return 1; return 1;
} }
@Override @Override
public String getInvName() { public String getInvName()
{
// TODO Auto-generated method stub // TODO Auto-generated method stub
return "RoboticArm"; return "RoboticArm";
} }
} }