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
* simple AI.
* AI.
*
* @author Calclavia
*
@ -32,11 +32,15 @@ public abstract class Task
* - The amount of ticks this task
* has been elapsed for.
*/
protected void onDoTask()
protected void doTask()
{
this.ticks++;
}
public void resetTask()
{
}
/**
* @return Whether the task should keep
* executing.

View file

@ -11,14 +11,16 @@ import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
public class TileEntityCraftingArm extends TileEntityBase implements IElectricityReceiver {
public class TileEntityCraftingArm extends TileEntityBase implements IElectricityReceiver
{
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;
@ -28,110 +30,109 @@ public class TileEntityCraftingArm extends TileEntityBase implements IElectricit
public double maxJoules = 100;
/**
* does this arm have a task to do
* does this arm have a task to do
*/
public boolean hasTask = true;
/**
* what kind of task this arm should do
*/
public armTasks task = armTasks.NONE;
public void 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.doWork();
}
}
/**
* controls the robotic arm into doing a set task
* controls the robotic arm into doing a set
* task
*/
public void doWork()
{
}
/**
* UE methods
*/
@Override
public void onReceive(TileEntity sender, double amps, double voltage,
ForgeDirection side) {
this.jouleReceived = Math.max(jouleReceived + (amps * voltage),
maxJoules);
public void onReceive(TileEntity sender, double amps, double voltage, ForgeDirection side)
{
this.jouleReceived = Math.max(jouleReceived + (amps * voltage), maxJoules);
}
@Override
public double wattRequest() {
public double wattRequest()
{
return maxJoules - jouleReceived;
}
@Override
public boolean canReceiveFromSide(ForgeDirection side) {
if (side != ForgeDirection.UP) {
return true;
}
public boolean canReceiveFromSide(ForgeDirection side)
{
if (side != ForgeDirection.UP) { return true; }
return false;
}
@Override
public void onDisable(int duration) {
public void onDisable(int duration)
{
// TODO Auto-generated method stub
}
@Override
public boolean isDisabled() {
public boolean isDisabled()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean canConnect(ForgeDirection side) {
if(side != ForgeDirection.UP)
{
return true;
}
public boolean canConnect(ForgeDirection side)
{
if (side != ForgeDirection.UP) { return true; }
return false;
}
@Override
public double getVoltage() {
public double getVoltage()
{
// TODO Auto-generated method stub
return 120;
}
/**
* Data
*/
@Override
public void handlePacketData(INetworkManager network, int packetType,
Packet250CustomPayload packet, EntityPlayer player,
ByteArrayDataInput dataStream) {
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
{
// TODO Auto-generated method stub
}
/**
* inventory
*/
@Override
public int getSizeInventory() {
public int getSizeInventory()
{
// TODO Auto-generated method stub
return 1;
}
@Override
public String getInvName() {
public String getInvName()
{
// TODO Auto-generated method stub
return "RoboticArm";
}
}