diff --git a/docs/B1iB0DI.png b/docs/B1iB0DI.png new file mode 100644 index 00000000..114dee8e Binary files /dev/null and b/docs/B1iB0DI.png differ diff --git a/resources/assets/al/textures/gui/logic/DEFINEDPROCESS.png b/resources/assets/al/textures/gui/logic/DEFINEDPROCESS.png new file mode 100644 index 00000000..c7716083 Binary files /dev/null and b/resources/assets/al/textures/gui/logic/DEFINEDPROCESS.png differ diff --git a/resources/assets/al/textures/gui/logic/IF.png b/resources/assets/al/textures/gui/logic/IF.png new file mode 100644 index 00000000..ca2deeae Binary files /dev/null and b/resources/assets/al/textures/gui/logic/IF.png differ diff --git a/resources/assets/al/textures/gui/logic/PROCESS.png b/resources/assets/al/textures/gui/logic/PROCESS.png new file mode 100644 index 00000000..5f56cc25 Binary files /dev/null and b/resources/assets/al/textures/gui/logic/PROCESS.png differ diff --git a/src/minecraft/dark/api/al/coding/IServo.java b/src/minecraft/dark/api/al/IServo.java similarity index 92% rename from src/minecraft/dark/api/al/coding/IServo.java rename to src/minecraft/dark/api/al/IServo.java index ee8af3c7..ba9f90b9 100644 --- a/src/minecraft/dark/api/al/coding/IServo.java +++ b/src/minecraft/dark/api/al/IServo.java @@ -1,4 +1,4 @@ -package dark.api.al.coding; +package dark.api.al; import universalelectricity.core.vector.Vector2; /** diff --git a/src/minecraft/dark/api/al/coding/IServoHandler.java b/src/minecraft/dark/api/al/IServoHandler.java similarity index 95% rename from src/minecraft/dark/api/al/coding/IServoHandler.java rename to src/minecraft/dark/api/al/IServoHandler.java index 5c24fd79..5d629055 100644 --- a/src/minecraft/dark/api/al/coding/IServoHandler.java +++ b/src/minecraft/dark/api/al/IServoHandler.java @@ -1,7 +1,8 @@ -package dark.api.al.coding; +package dark.api.al; import java.util.HashMap; + /** Container like class to handle several servos in an object. * * @author DarkGuardsman */ diff --git a/src/minecraft/dark/api/al/coding/ILogicTask.java b/src/minecraft/dark/api/al/coding/ILogicTask.java new file mode 100644 index 00000000..0653356a --- /dev/null +++ b/src/minecraft/dark/api/al/coding/ILogicTask.java @@ -0,0 +1,20 @@ +package dark.api.al.coding; + +/** Task in which it doesn't go right to the next task in the row. In this case the task will store + * the entry point, and exit points. As well handle anything in between. Examples are IF statements + * and loops. + * + * @author DarkGuardsman */ +public interface ILogicTask extends IProcessTask +{ + /** There is always only one exit though you can do logic to pick from all your exit points. Exit + * is the next task rather than the exit of the statement. Use #IRedirectTask to force the logic back to this task. */ + public IProcessTask getExitPoint(); + + /** Mainly used by the encoder to understand the limit on connections */ + public int getMaxExitPoints(); + + /** Adds a possible exit point to the split off */ + public void addExitPoint(IProcessTask task); + +} diff --git a/src/minecraft/dark/api/al/coding/IDeviceTask.java b/src/minecraft/dark/api/al/coding/IProcessTask.java similarity index 63% rename from src/minecraft/dark/api/al/coding/IDeviceTask.java rename to src/minecraft/dark/api/al/coding/IProcessTask.java index e79dc0d9..c2a7f96b 100644 --- a/src/minecraft/dark/api/al/coding/IDeviceTask.java +++ b/src/minecraft/dark/api/al/coding/IProcessTask.java @@ -20,20 +20,8 @@ import dark.api.al.coding.args.ArgumentData; * the task. That way it can save values after the task has been refreshed or even deleted. * * @author DarkGuardsman */ -public interface IDeviceTask extends Cloneable +public interface IProcessTask extends ITask { - /** Location in the column and row format. */ - public Vector2 getPosition(); - - public void setPosition(Vector2 pos); - - /** Method name or rather command name this will be called. Uses both to ID this command, and do - * basic command structuring. */ - public String getMethodName(); - - /** Should be the same as getMethodName() but can be different */ - public String getCCMethod(); - /** Passed in from the device to the program manager then here after a Computer craft machine * calls a this commands method name. {@IPeripheral #callMethod()} */ public Object[] onCCMethodCalled(World world, Vector3 location, IProgramableMachine device, IComputerAccess computer, ILuaContext context) throws Exception; @@ -54,24 +42,6 @@ public interface IDeviceTask extends Cloneable /** Called when the task is finish and then cleared */ public void terminated(); - /** Read the command from the armbot save. */ - public IDeviceTask load(NBTTagCompound nbt); - - /** Writes the command to the armbot save. Should only be used to save the data used to recreate - * a new version of this command */ - public NBTTagCompound save(NBTTagCompound nbt); - - /** Saves the current progress of the current command */ - public IDeviceTask loadProgress(NBTTagCompound nbt); - - /** Reads the progress of the command if it was saved mid process */ - public NBTTagCompound saveProgress(NBTTagCompound nbt); - - public TaskType getType(); - - /** Can this task function for this machine */ - public boolean canUseTask(IProgramableMachine device); - /** ArgumentData used to both restrict and set values into the argument hashmap */ public List getEncoderParms(); @@ -81,21 +51,8 @@ public interface IDeviceTask extends Cloneable /** Get all given arguments */ public HashMap getArgs(); - /** Used mainly for display purposes in the encoder */ - public static enum TaskType - { - DATA("Data"), - DEFINEDPROCESS("Defined Process"), - PROCESS("Process"), - DECISION("Decision"); - public ResourceLocation blockTexure; - public String name; - - private TaskType(String name) - { - this.name = name; - } - } + /** Get all given arguments */ + public void setArgs(HashMap args); public static enum ProcessReturn { @@ -113,5 +70,4 @@ public interface IDeviceTask extends Cloneable } } - public IDeviceTask clone(); } diff --git a/src/minecraft/dark/api/al/coding/IProgram.java b/src/minecraft/dark/api/al/coding/IProgram.java index ba9a168c..b02a4246 100644 --- a/src/minecraft/dark/api/al/coding/IProgram.java +++ b/src/minecraft/dark/api/al/coding/IProgram.java @@ -10,7 +10,7 @@ import universalelectricity.core.vector.Vector2; * Column and row based system. * * @author DarkGuardsman */ -public interface IProgram +public interface IProgram extends Cloneable { /** Called when the program is added to an encoder, machine, or devices. */ public void init(); @@ -20,17 +20,23 @@ public interface IProgram public HashMap getDeclairedVarables(); /** Next task in the set. Its up to the program to increment down the list */ - public IDeviceTask getNextTask(); + public ITask getNextTask(); /** Gets a task at the given x y location in the program */ - public IDeviceTask getTaskAt(Vector2 vector2); + public ITask getTaskAt(Vector2 vector2); - public void setTaskAt(Vector2 vector2, IDeviceTask task); + /** Returns the entire program as a map as grid locations and tasks. */ + public HashMap getTaskMap(); - /** Return this program to its starting conditions - * - * @full - means full reset including memory clean */ - public void reset(boolean full); + /** Sets the task at the point overriding what was there. If the task is null remove it and shift + * everything up one */ + public void setTaskAt(Vector2 vector2, ITask task); + + /** Inserts a task at the point. If a task is already there everything should shift down 1 */ + public void insertTask(Vector2 vector2, ITask task); + + /** Return this program to its starting conditions */ + public void reset(); /** Sets the declared variable */ public void setVar(String name, Object object); diff --git a/src/minecraft/dark/api/al/coding/IRedirectTask.java b/src/minecraft/dark/api/al/coding/IRedirectTask.java new file mode 100644 index 00000000..d456d01f --- /dev/null +++ b/src/minecraft/dark/api/al/coding/IRedirectTask.java @@ -0,0 +1,12 @@ +package dark.api.al.coding; + +/** Used to tell the program that this task is used to tell the program were to go next. Used by + * things like LOOP, IF, and GOTO statement's end catches. Not actually used by the statement itself + * other than to help control the flow of the program + * + * @author DarkGuardsman */ +public interface IRedirectTask extends IProcessTask +{ + /** Were does this task redirect to */ + public IProcessTask getExit(); +} diff --git a/src/minecraft/dark/api/al/coding/ISplitArmbotTask.java b/src/minecraft/dark/api/al/coding/ISplitArmbotTask.java deleted file mode 100644 index 204b6895..00000000 --- a/src/minecraft/dark/api/al/coding/ISplitArmbotTask.java +++ /dev/null @@ -1,26 +0,0 @@ -package dark.api.al.coding; - -/** Task in which it doesn't go right to the next task in the row. In this case the task will store - * the entry point, and exit points. As well handle anything in between. Examples are IF statements - * and loops. - * - * @author DarkGuardsman */ -public interface ISplitArmbotTask extends IDeviceTask -{ - /** Point were this task is entered from. Normally is the task above it, and is never used. */ - public IDeviceTask getEntryPoint(); - - /** There is always only one exit though you can do logic to pick from all your exit points */ - public IDeviceTask getExitPoint(); - - /** Mainly used by the coder to understand the limit on connections */ - public int getMaxExitPoints(); - - /** Set by the coder, or when this is clone, to say what task was before this. */ - public ISplitArmbotTask setEntryPoint(IDeviceTask task); - - /** Adds a possible exit point to the split off */ - public void addExitPoint(IDeviceTask task); - - -} diff --git a/src/minecraft/dark/api/al/coding/ITask.java b/src/minecraft/dark/api/al/coding/ITask.java new file mode 100644 index 00000000..ac77c0ae --- /dev/null +++ b/src/minecraft/dark/api/al/coding/ITask.java @@ -0,0 +1,56 @@ +package dark.api.al.coding; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; +import universalelectricity.core.vector.Vector2; + +public interface ITask extends Cloneable +{ + /** Location in the column and row format. */ + public Vector2 getPosition(); + + public void setPosition(Vector2 pos); + + /** Method name or rather command name this will be called. Uses both to ID this command, and do + * basic command structuring. */ + public String getMethodName(); + + /** Type of task used mainly for GUI displays */ + public TaskType getType(); + + /** Read the command from the armbot save. */ + public ITask load(NBTTagCompound nbt); + + /** Writes the command to the armbot save. Should only be used to save the data used to recreate + * a new version of this command */ + public NBTTagCompound save(NBTTagCompound nbt); + + /** Saves the current progress of the current command */ + public IProcessTask loadProgress(NBTTagCompound nbt); + + /** Reads the progress of the command if it was saved mid process */ + public NBTTagCompound saveProgress(NBTTagCompound nbt); + + /** Can this task function for this machine */ + public boolean canUseTask(IProgramableMachine device); + + /** Used to create a new task from this task. Make sure to return a fresh copy without anything. + * This includes no arguments, progress, varables, etc. */ + public ITask clone(); + + /** Used mainly for display purposes in the encoder */ + public static enum TaskType + { + DATA("Data"), + DEFINEDPROCESS("Defined Process"), + PROCESS("Process"), + DECISION("Decision"); + public ResourceLocation blockTexure; + public String name; + + private TaskType(String name) + { + this.name = name; + } + } +} diff --git a/src/minecraft/dark/api/al/coding/ProgramHelper.java b/src/minecraft/dark/api/al/coding/ProgramHelper.java index 336fe1bf..a0e632a7 100644 --- a/src/minecraft/dark/api/al/coding/ProgramHelper.java +++ b/src/minecraft/dark/api/al/coding/ProgramHelper.java @@ -2,14 +2,16 @@ package dark.api.al.coding; import java.util.HashMap; -import dark.api.al.coding.IDeviceTask.ProcessReturn; +import dark.api.al.coding.IProcessTask.ProcessReturn; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import universalelectricity.core.vector.Vector3; -/** Basic class to handle a armbot like programs for any object that uses the IArmbot class +/** Basic class to handle a machine like programs for any object that uses the IProgramable + * interface. Doesn't actually do much then tell the program to function, and stores the programs + * active run time memory. * * @author DarkGuardsman */ public class ProgramHelper @@ -18,7 +20,7 @@ public class ProgramHelper protected IProgram program; protected IProgramableMachine bot; /** Current task in program */ - protected IDeviceTask currentTask; + protected ITask currentTask; /** Do we have a memory to store values */ boolean hasMemory = false; boolean hasTaskBeenCalled = false, nextTask = false; @@ -46,23 +48,31 @@ public class ProgramHelper } if (this.currentTask != null) { - if (!this.hasTaskBeenCalled) + if (this.currentTask instanceof IProcessTask) { - re = this.currentTask.onMethodCalled(world, botLocation, bot); + if (!this.hasTaskBeenCalled) + { + this.hasTaskBeenCalled = true; + re = ((IProcessTask) this.currentTask).onMethodCalled(world, botLocation, bot); + if (re == ProcessReturn.DONE) + { + this.nextTask = true; + } + else if (re != ProcessReturn.CONTINUE) + { + return re; + } + } + + re = ((IProcessTask) this.currentTask).onUpdate(); if (re == ProcessReturn.DONE) { this.nextTask = true; } - else if (re != ProcessReturn.CONTINUE) - { - return re; - } } - - re = this.currentTask.onUpdate(); - if (re == ProcessReturn.DONE) + else { - this.nextTask = true; + re = ProcessReturn.CONTINUE; } return re; } diff --git a/src/minecraft/dark/api/al/coding/TaskRegistry.java b/src/minecraft/dark/api/al/coding/TaskRegistry.java index ed31e78e..34c11429 100644 --- a/src/minecraft/dark/api/al/coding/TaskRegistry.java +++ b/src/minecraft/dark/api/al/coding/TaskRegistry.java @@ -15,12 +15,12 @@ public class TaskRegistry /** A class of all available commands. * * String - Command name. Command - The actual command class. */ - private static final HashMap COMMANDS = new HashMap(); + private static final HashMap COMMANDS = new HashMap(); private static final HashMap SUDO_BOTS = new HashMap(); /** Registers a command and tells armbots that it exists */ - public static void registerCommand(IDeviceTask task) + public static void registerCommand(IProcessTask task) { if (!COMMANDS.containsKey(task.getMethodName())) { @@ -28,7 +28,7 @@ public class TaskRegistry } } - public static void registerCommand(String registryName, IDeviceTask task) + public static void registerCommand(String registryName, IProcessTask task) { if (!COMMANDS.containsKey(registryName)) { @@ -37,9 +37,9 @@ public class TaskRegistry } /** returns the first command with the same name */ - public static IDeviceTask getCommand(String name) + public static IProcessTask getCommand(String name) { - for (Entry command : COMMANDS.entrySet()) + for (Entry command : COMMANDS.entrySet()) { if (command.getKey().equalsIgnoreCase(name)) { @@ -50,10 +50,10 @@ public class TaskRegistry } /** Gets all commands with the given name though there should only be one */ - public static List getCommands(String name) + public static List getCommands(String name) { - List tasks = new ArrayList(); - for (Entry command : COMMANDS.entrySet()) + List tasks = new ArrayList(); + for (Entry command : COMMANDS.entrySet()) { if (command.getValue().getMethodName().equalsIgnoreCase(name)) { diff --git a/src/minecraft/dark/assembly/common/armbot/Program.java b/src/minecraft/dark/assembly/common/armbot/Program.java index 67a7a2b3..68859496 100644 --- a/src/minecraft/dark/assembly/common/armbot/Program.java +++ b/src/minecraft/dark/assembly/common/armbot/Program.java @@ -1,20 +1,26 @@ package dark.assembly.common.armbot; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map.Entry; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import universalelectricity.core.vector.Vector2; -import dark.api.al.coding.IDeviceTask; import dark.api.al.coding.IProgram; +import dark.api.al.coding.ITask; import dark.api.al.coding.TaskRegistry; +import dark.core.prefab.helpers.NBTFileHelper; public class Program implements IProgram { protected Vector2 currentPos = new Vector2(0, 0); - protected IDeviceTask currentTask; - protected HashMap tasks = new HashMap(); + protected ITask currentTask; + protected HashMap tasks = new HashMap(); + protected HashMap varables = new HashMap(); + protected int width = 0, hight = 0; + boolean started = false; @Override public void init() @@ -26,20 +32,22 @@ public class Program implements IProgram @Override public HashMap getDeclairedVarables() { - // TODO Auto-generated method stub - return null; + return varables; } @Override - public IDeviceTask getNextTask() + public ITask getNextTask() { - this.currentTask = this.getTaskAt(currentPos); - this.currentPos.add(new Vector2(1, 0)); + if (!started) + { + this.currentTask = this.getTaskAt(currentPos); + this.currentPos.add(new Vector2(1, 0)); + } return this.currentTask; } @Override - public IDeviceTask getTaskAt(Vector2 vector2) + public ITask getTaskAt(Vector2 vector2) { if (vector2 != null) { @@ -49,66 +57,200 @@ public class Program implements IProgram } @Override - public void setTaskAt(Vector2 vector2, IDeviceTask task) + public HashMap getTaskMap() + { + return this.tasks; + } + + @Override + public void setTaskAt(Vector2 vector2, ITask task) { if (vector2 != null) { if (task != null) { + if (task.getPosition().x > this.width) + { + this.width = (int) task.getPosition().x; + } + if (task.getPosition().y > this.hight) + { + this.hight = (int) task.getPosition().y; + } this.tasks.put(new Vector2(vector2.intX(), vector2.intY()), task); } else if (this.tasks.containsKey(vector2)) { this.tasks.remove(vector2); + if (task.getPosition().intY() == this.hight && !this.isThereATaskInRow(this.hight)) + { + this.hight--; + } + else if (!this.isThereATaskInRow(vector2.intY())) + { + this.moveAll(vector2.intY(), true); + } + } + } + } + + public boolean isThereATaskInRow(int row) + { + Vector2 vec = new Vector2(0, row); + Vector2 slide = new Vector2(1, 0); + for (int x = 0; x <= this.width; x++) + { + if (this.getTaskAt(vec) != null) + { + return true; + } + vec.add(slide); + } + return false; + } + + public boolean isThereATaskInColume(int colume) + { + Vector2 vec = new Vector2(colume, 0); + Vector2 slide = new Vector2(0, 1); + for (int y = 0; y <= this.width; y++) + { + if (this.getTaskAt(vec) != null) + { + return true; + } + vec.add(slide); + } + return false; + } + + /** Move all tasks at the row and in the direction given. + * + * @param row - row number or Y value of the position from the task + * @param up - true will move all the tasks up one, false will move all the tasks down one */ + public void moveAll(int row, boolean up) + { + List moveList = new ArrayList(); + final Vector2 moveDown = up ? new Vector2(-1, 0) : new Vector2(1, 0); + Vector2 targetPos; + ITask tagetTask; + /* Gather all task and remove them so they can be re-added wither there new positions */ + for (int x = 0; x <= this.width; x++) + { + for (int y = row; y <= this.hight; y++) + { + targetPos = new Vector2(x, y); + tagetTask = this.getTaskAt(targetPos); + if (tagetTask != null) + { + //Add the task to the move list + moveList.add(tagetTask); + //Removes the task + this.tasks.remove(targetPos); + } + } + } + /* Update all the task locations */ + for (ITask moveTask : moveList) + { + moveTask.setPosition(moveTask.getPosition().add(moveDown)); + this.setTaskAt(moveTask.getPosition(), moveTask); + } + //TODO send to the client the updates map and key to unlock the delete button + } + + @Override + public void insertTask(Vector2 vector2, ITask task) + { + if (vector2 != null && task != null) + { + if (this.getTaskAt(vector2) != null) + { + this.moveAll(vector2.intY(), false); + } + else + { + this.setTaskAt(vector2, task); } } } @Override - public void reset(boolean full) + public void reset() { - this.currentTask = null; + if (this.currentTask != null) + { + NBTTagCompound tag = this.currentTask.save(new NBTTagCompound()); + this.currentTask = TaskRegistry.getCommand(this.currentTask.getMethodName()).clone(); + this.currentTask.load(tag); + this.setTaskAt(this.currentTask.getPosition(), this.currentTask); + this.currentTask = null; + } + this.currentPos = new Vector2(0, 0); } @Override public void setVar(String name, Object object) { - // TODO Auto-generated method stub + if (name != null) + { + if (object != null) + { + this.varables.put(name, object); + } + else + { + this.varables.remove(name); + } + } } @Override public Object getVar(String name) { - // TODO Auto-generated method stub - return null; + return this.varables.get(name); } @Override public NBTTagCompound save(NBTTagCompound nbt) { + //Save process list NBTTagList taskList = new NBTTagList(); - for (Entry entry : this.tasks.entrySet()) + for (Entry entry : this.tasks.entrySet()) { entry.getValue().setPosition(entry.getKey()); NBTTagCompound task = entry.getValue().save(new NBTTagCompound()); + if (entry.getKey().equals(this.currentTask.getPosition())) + { + task.setBoolean("currentTask", true); + entry.getValue().saveProgress(task); + } task.setString("methodName", entry.getValue().getMethodName()); task.setInteger("positionX", entry.getKey().intX()); task.setInteger("positionY", entry.getKey().intY()); taskList.appendTag(task); } nbt.setTag("tasks", taskList); + //save varables + taskList = new NBTTagList(); + for (Entry var : this.varables.entrySet()) + { + taskList.appendTag(NBTFileHelper.saveObject(var.getKey(), var.getValue())); + } + nbt.setTag("vars", taskList); return nbt; } @Override public void load(NBTTagCompound nbt) { + //Load process list NBTTagList taskList = nbt.getTagList("tasks"); for (int s = 0; s < taskList.tagCount(); ++s) { NBTTagCompound tag = (NBTTagCompound) taskList.tagAt(s); - IDeviceTask task = TaskRegistry.getCommand(tag.getString("methodName")); + ITask task = TaskRegistry.getCommand(tag.getString("methodName")); if (task != null) { task = task.clone(); @@ -117,10 +259,38 @@ public class Program implements IProgram task.load(tag); task.setPosition(new Vector2(nbt.getInteger("positionX"), nbt.getInteger("positionY"))); this.tasks.put(task.getPosition(), task); + if (tag.getBoolean("currentTask")) + { + this.currentTask = task; + task.loadProgress(tag); + this.currentPos = task.getPosition(); + } + if (task.getPosition().x > this.width) + { + this.width = (int) task.getPosition().x; + } + if (task.getPosition().y > this.hight) + { + this.hight = (int) task.getPosition().y; + } } } } + taskList = nbt.getTagList("vars"); + for (int s = 0; s < taskList.tagCount(); ++s) + { + NBTTagCompound tag = (NBTTagCompound) taskList.tagAt(s); + this.varables.put(tag.getName(), NBTFileHelper.loadObject(tag, tag.getName())); + } + } + @Override + public Program clone() + { + Program program = new Program(); + program.load(this.save(new NBTTagCompound())); + program.reset(); + return program; } } diff --git a/src/minecraft/dark/assembly/common/armbot/TaskBase.java b/src/minecraft/dark/assembly/common/armbot/TaskBase.java index 3858a74f..ba2f682a 100644 --- a/src/minecraft/dark/assembly/common/armbot/TaskBase.java +++ b/src/minecraft/dark/assembly/common/armbot/TaskBase.java @@ -5,29 +5,26 @@ import java.util.HashMap; import java.util.List; import java.util.Map.Entry; -import com.builtbroken.common.science.units.UnitHelper; - import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; import universalelectricity.core.vector.Vector2; import universalelectricity.core.vector.Vector3; + +import com.builtbroken.common.science.units.UnitHelper; + import dan200.computer.api.IComputerAccess; import dan200.computer.api.ILuaContext; -import dark.api.al.coding.IArmbot; -import dark.api.al.coding.IDeviceTask; -import dark.api.al.coding.IProgramableMachine; +import dark.api.al.coding.IProcessTask; import dark.api.al.coding.IMemoryTask; import dark.api.al.coding.IProgram; -import dark.api.al.coding.IDeviceTask.TaskType; +import dark.api.al.coding.IProgramableMachine; import dark.api.al.coding.args.ArgumentData; -import dark.core.prefab.helpers.NBTFileLoader; +import dark.core.prefab.helpers.NBTFileHelper; /** Basic command prefab used by machines like an armbot. You are not required to use this in order * to make armbot commands but it does help. Delete this if you don't plan to use it. */ -public abstract class TaskBase implements IDeviceTask, IMemoryTask +public abstract class TaskBase implements IProcessTask, IMemoryTask { /** Program this is part of. Can be null while stores as a prefab waiting to be copied */ protected IProgram program; @@ -140,7 +137,7 @@ public abstract class TaskBase implements IDeviceTask, IMemoryTask NBTTagCompound parms = nbt.getCompoundTag("args"); for (ArgumentData arg : this.getEncoderParms()) { - Object obj = NBTFileLoader.loadObject(parms, arg.getName()); + Object obj = NBTFileHelper.loadObject(parms, arg.getName()); if (arg.isValid(obj)) { this.aruguments.put(arg.getName(), obj); @@ -157,7 +154,7 @@ public abstract class TaskBase implements IDeviceTask, IMemoryTask NBTTagCompound parms = new NBTTagCompound(); for (Entry entry : this.aruguments.entrySet()) { - NBTFileLoader.saveObject(parms, entry.getKey(), entry.getValue()); + NBTFileHelper.saveObject(parms, entry.getKey(), entry.getValue()); } nbt.setCompoundTag("args", parms); if (this.pos != null) @@ -169,7 +166,7 @@ public abstract class TaskBase implements IDeviceTask, IMemoryTask } @Override - public IDeviceTask loadProgress(NBTTagCompound nbt) + public IProcessTask loadProgress(NBTTagCompound nbt) { return this; } @@ -192,12 +189,6 @@ public abstract class TaskBase implements IDeviceTask, IMemoryTask return this.methodName; } - @Override - public String getCCMethod() - { - return this.methodName; - } - @Override public TaskType getType() { diff --git a/src/minecraft/dark/assembly/common/armbot/command/CommandBreak.java b/src/minecraft/dark/assembly/common/armbot/command/CommandBreak.java index 258798bb..14d4fc5d 100644 --- a/src/minecraft/dark/assembly/common/armbot/command/CommandBreak.java +++ b/src/minecraft/dark/assembly/common/armbot/command/CommandBreak.java @@ -7,8 +7,8 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import universalelectricity.core.vector.Vector3; -import dark.api.al.coding.IDeviceTask; -import dark.api.al.coding.IDeviceTask.TaskType; +import dark.api.al.coding.IProcessTask; +import dark.api.al.coding.IProcessTask.TaskType; import dark.assembly.common.armbot.TaskBase; import dark.assembly.common.armbot.TaskArmbot; import dark.core.prefab.helpers.ItemWorldHelper; @@ -71,7 +71,7 @@ public class CommandBreak extends TaskArmbot } @Override - public IDeviceTask loadProgress(NBTTagCompound nbt) + public IProcessTask loadProgress(NBTTagCompound nbt) { this.breakTicks = nbt.getInteger("breakTicks"); return this; diff --git a/src/minecraft/dark/assembly/common/armbot/command/CommandDrop.java b/src/minecraft/dark/assembly/common/armbot/command/CommandDrop.java index a8cc0e18..76b891d2 100644 --- a/src/minecraft/dark/assembly/common/armbot/command/CommandDrop.java +++ b/src/minecraft/dark/assembly/common/armbot/command/CommandDrop.java @@ -1,8 +1,8 @@ package dark.assembly.common.armbot.command; import net.minecraft.nbt.NBTTagCompound; -import dark.api.al.coding.IDeviceTask; -import dark.api.al.coding.IDeviceTask.TaskType; +import dark.api.al.coding.IProcessTask; +import dark.api.al.coding.IProcessTask.TaskType; import dark.assembly.common.armbot.TaskBase; import dark.assembly.common.armbot.TaskArmbot; diff --git a/src/minecraft/dark/assembly/common/armbot/command/CommandFire.java b/src/minecraft/dark/assembly/common/armbot/command/CommandFire.java index 5dd21621..c0963088 100644 --- a/src/minecraft/dark/assembly/common/armbot/command/CommandFire.java +++ b/src/minecraft/dark/assembly/common/armbot/command/CommandFire.java @@ -7,7 +7,7 @@ import com.builtbroken.common.science.units.UnitHelper; import dark.api.al.coding.IArmbot; import dark.api.al.coding.IProgramableMachine; -import dark.api.al.coding.IDeviceTask.TaskType; +import dark.api.al.coding.IProcessTask.TaskType; import dark.api.al.coding.args.ArgumentData; import dark.api.al.coding.args.ArgumentFloatData; import dark.assembly.common.armbot.TaskBase; diff --git a/src/minecraft/dark/assembly/common/armbot/command/CommandHarvest.java b/src/minecraft/dark/assembly/common/armbot/command/CommandHarvest.java index e354fc49..041aa93e 100644 --- a/src/minecraft/dark/assembly/common/armbot/command/CommandHarvest.java +++ b/src/minecraft/dark/assembly/common/armbot/command/CommandHarvest.java @@ -4,7 +4,7 @@ import net.minecraft.world.World; import universalelectricity.core.vector.Vector3; import dark.api.al.coding.IArmbot; import dark.api.al.coding.IProgramableMachine; -import dark.api.al.coding.IDeviceTask.TaskType; +import dark.api.al.coding.IProcessTask.TaskType; /** Used by arms to break a specific block in a position. * diff --git a/src/minecraft/dark/assembly/common/armbot/command/CommandIdle.java b/src/minecraft/dark/assembly/common/armbot/command/CommandIdle.java index 90cb2e57..7f2207cc 100644 --- a/src/minecraft/dark/assembly/common/armbot/command/CommandIdle.java +++ b/src/minecraft/dark/assembly/common/armbot/command/CommandIdle.java @@ -5,7 +5,7 @@ import com.builtbroken.common.science.units.UnitHelper; import universalelectricity.core.vector.Vector3; import dark.api.al.coding.IArmbot; import dark.api.al.coding.IProgramableMachine; -import dark.api.al.coding.IDeviceTask.TaskType; +import dark.api.al.coding.IProcessTask.TaskType; import dark.api.al.coding.args.ArgumentData; import dark.assembly.common.armbot.TaskBase; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/minecraft/dark/assembly/common/armbot/command/CommandPlace.java b/src/minecraft/dark/assembly/common/armbot/command/CommandPlace.java index 0f68662c..9b3f315d 100644 --- a/src/minecraft/dark/assembly/common/armbot/command/CommandPlace.java +++ b/src/minecraft/dark/assembly/common/armbot/command/CommandPlace.java @@ -1,6 +1,6 @@ package dark.assembly.common.armbot.command; -import dark.api.al.coding.IDeviceTask.TaskType; +import dark.api.al.coding.IProcessTask.TaskType; import dark.assembly.common.armbot.TaskBase; import dark.assembly.common.armbot.TaskArmbot; import net.minecraft.block.Block; diff --git a/src/minecraft/dark/assembly/common/armbot/command/CommandRotateBy.java b/src/minecraft/dark/assembly/common/armbot/command/CommandRotateBy.java index 5497a982..c431cb1f 100644 --- a/src/minecraft/dark/assembly/common/armbot/command/CommandRotateBy.java +++ b/src/minecraft/dark/assembly/common/armbot/command/CommandRotateBy.java @@ -4,8 +4,8 @@ import com.builtbroken.common.science.units.UnitHelper; import universalelectricity.core.vector.Vector3; import dark.api.al.coding.IProgramableMachine; -import dark.api.al.coding.IDeviceTask.ProcessReturn; -import dark.api.al.coding.IDeviceTask.TaskType; +import dark.api.al.coding.IProcessTask.ProcessReturn; +import dark.api.al.coding.IProcessTask.TaskType; import dark.api.al.coding.args.ArgumentIntData; import dark.assembly.common.armbot.TaskBase; import dark.assembly.common.armbot.TaskArmbot; diff --git a/src/minecraft/dark/assembly/common/armbot/command/CommandRotateTo.java b/src/minecraft/dark/assembly/common/armbot/command/CommandRotateTo.java index 0049b376..1994262c 100644 --- a/src/minecraft/dark/assembly/common/armbot/command/CommandRotateTo.java +++ b/src/minecraft/dark/assembly/common/armbot/command/CommandRotateTo.java @@ -6,7 +6,7 @@ import com.builtbroken.common.science.units.UnitHelper; import dark.api.al.coding.IArmbot; import dark.api.al.coding.IProgramableMachine; -import dark.api.al.coding.IDeviceTask.TaskType; +import dark.api.al.coding.IProcessTask.TaskType; import dark.api.al.coding.args.ArgumentIntData; import dark.assembly.common.armbot.TaskBase; import dark.assembly.common.armbot.TaskArmbot; diff --git a/src/minecraft/dark/assembly/common/armbot/command/CommandTake.java b/src/minecraft/dark/assembly/common/armbot/command/CommandTake.java index 66bcfa7c..49c6ebff 100644 --- a/src/minecraft/dark/assembly/common/armbot/command/CommandTake.java +++ b/src/minecraft/dark/assembly/common/armbot/command/CommandTake.java @@ -14,7 +14,7 @@ import universalelectricity.core.vector.Vector3; import com.builtbroken.common.science.units.UnitHelper; import dark.api.al.coding.IProgramableMachine; -import dark.api.al.coding.IDeviceTask.ProcessReturn; +import dark.api.al.coding.IProcessTask.ProcessReturn; import dark.api.al.coding.args.ArgumentIntData; import dark.assembly.common.armbot.TaskArmbot; import dark.assembly.common.armbot.TaskBase; diff --git a/src/minecraft/dark/assembly/common/armbot/command/CommandUse.java b/src/minecraft/dark/assembly/common/armbot/command/CommandUse.java index 86052e19..ffc955a1 100644 --- a/src/minecraft/dark/assembly/common/armbot/command/CommandUse.java +++ b/src/minecraft/dark/assembly/common/armbot/command/CommandUse.java @@ -8,10 +8,10 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import dark.api.al.coding.IArmbotUseable; -import dark.api.al.coding.IDeviceTask; +import dark.api.al.coding.IProcessTask; import dark.api.al.coding.IProgramableMachine; -import dark.api.al.coding.IDeviceTask.ProcessReturn; -import dark.api.al.coding.IDeviceTask.TaskType; +import dark.api.al.coding.IProcessTask.ProcessReturn; +import dark.api.al.coding.IProcessTask.TaskType; import dark.api.al.coding.args.ArgumentData; import dark.api.al.coding.args.ArgumentIntData; import dark.assembly.common.armbot.TaskBase; @@ -100,7 +100,7 @@ public class CommandUse extends TaskArmbot } @Override - public IDeviceTask loadProgress(NBTTagCompound nbt) + public IProcessTask loadProgress(NBTTagCompound nbt) { this.curTimes = nbt.getInteger("useCurTimes"); return this; diff --git a/src/minecraft/dark/assembly/common/armbot/command/TaskIF.java b/src/minecraft/dark/assembly/common/armbot/command/TaskIF.java index 0a6887c4..58c63c4a 100644 --- a/src/minecraft/dark/assembly/common/armbot/command/TaskIF.java +++ b/src/minecraft/dark/assembly/common/armbot/command/TaskIF.java @@ -2,16 +2,16 @@ package dark.assembly.common.armbot.command; import universalelectricity.core.vector.Vector2; import net.minecraft.nbt.NBTTagCompound; -import dark.api.al.coding.IDeviceTask; +import dark.api.al.coding.IProcessTask; import dark.api.al.coding.IProgramableMachine; -import dark.api.al.coding.ISplitArmbotTask; +import dark.api.al.coding.ILogicTask; import dark.assembly.common.armbot.TaskBase; -public class TaskIF extends TaskBase implements ISplitArmbotTask +public class TaskIF extends TaskBase implements ILogicTask { - protected IDeviceTask entryPoint = null; - protected IDeviceTask exitTruePoint = null; - protected IDeviceTask exitFalsePoint = null; + protected IProcessTask entryPoint = null; + protected IProcessTask exitTruePoint = null; + protected IProcessTask exitFalsePoint = null; protected boolean isTrue = false; public TaskIF() @@ -19,7 +19,7 @@ public class TaskIF extends TaskBase implements ISplitArmbotTask super("IF", TaskType.DECISION); } - public TaskIF(IDeviceTask entryPoint, IDeviceTask trueExit, IDeviceTask falseExit) + public TaskIF(IProcessTask entryPoint, IProcessTask trueExit, IProcessTask falseExit) { this(); this.setEntryPoint(this.entryPoint); @@ -35,13 +35,13 @@ public class TaskIF extends TaskBase implements ISplitArmbotTask } @Override - public IDeviceTask getEntryPoint() + public IProcessTask getEntryPoint() { return this.entryPoint; } @Override - public IDeviceTask getExitPoint() + public IProcessTask getExitPoint() { if (this.isTrue) { @@ -57,14 +57,14 @@ public class TaskIF extends TaskBase implements ISplitArmbotTask } @Override - public ISplitArmbotTask setEntryPoint(IDeviceTask task) + public ILogicTask setEntryPoint(IProcessTask task) { this.entryPoint = task; return this; } @Override - public void addExitPoint(IDeviceTask task) + public void addExitPoint(IProcessTask task) { // TODO Auto-generated method stub diff --git a/src/minecraft/dark/assembly/common/armbot/command/TaskLoop.java b/src/minecraft/dark/assembly/common/armbot/command/TaskLoop.java index a3fb7485..f6748188 100644 --- a/src/minecraft/dark/assembly/common/armbot/command/TaskLoop.java +++ b/src/minecraft/dark/assembly/common/armbot/command/TaskLoop.java @@ -4,10 +4,10 @@ import com.builtbroken.common.science.units.UnitHelper; import universalelectricity.core.vector.Vector2; import universalelectricity.core.vector.Vector3; -import dark.api.al.coding.IDeviceTask; +import dark.api.al.coding.IProcessTask; import dark.api.al.coding.IProgramableMachine; -import dark.api.al.coding.ISplitArmbotTask; -import dark.api.al.coding.IDeviceTask.TaskType; +import dark.api.al.coding.ILogicTask; +import dark.api.al.coding.IProcessTask.TaskType; import dark.api.al.coding.args.ArgumentIntData; import dark.assembly.common.armbot.TaskBase; import net.minecraft.nbt.NBTTagCompound; @@ -16,10 +16,10 @@ import net.minecraft.world.World; /** Basic While loop that mainly handles number of repeats. * * @author DarkGuardsman */ -public class TaskLoop extends TaskBase implements ISplitArmbotTask +public class TaskLoop extends TaskBase implements ILogicTask { protected int numReps = -1; - protected IDeviceTask entry, exit; + protected IProcessTask entry, exit; public TaskLoop() { @@ -27,7 +27,7 @@ public class TaskLoop extends TaskBase implements ISplitArmbotTask this.defautlArguments.add(new ArgumentIntData("loop", 1, Integer.MAX_VALUE, -1)); } - public TaskLoop(IDeviceTask entry, IDeviceTask exit) + public TaskLoop(IProcessTask entry, IProcessTask exit) { this(); this.entry = entry; @@ -49,13 +49,13 @@ public class TaskLoop extends TaskBase implements ISplitArmbotTask } @Override - public IDeviceTask getEntryPoint() + public IProcessTask getEntryPoint() { return this.entry; } @Override - public IDeviceTask getExitPoint() + public IProcessTask getExitPoint() { return this.exit; } @@ -67,14 +67,14 @@ public class TaskLoop extends TaskBase implements ISplitArmbotTask } @Override - public ISplitArmbotTask setEntryPoint(IDeviceTask task) + public ILogicTask setEntryPoint(IProcessTask task) { this.entry = task; return this; } @Override - public void addExitPoint(IDeviceTask task) + public void addExitPoint(IProcessTask task) { this.exit = task; } diff --git a/src/minecraft/dark/assembly/common/machine/encoder/TileEntityEncoder.java b/src/minecraft/dark/assembly/common/machine/encoder/TileEntityEncoder.java index c361757e..810f31d9 100644 --- a/src/minecraft/dark/assembly/common/machine/encoder/TileEntityEncoder.java +++ b/src/minecraft/dark/assembly/common/machine/encoder/TileEntityEncoder.java @@ -13,7 +13,7 @@ import com.google.common.io.ByteArrayDataInput; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.Player; -import dark.api.al.coding.IDeviceTask; +import dark.api.al.coding.IProcessTask; import dark.api.al.coding.IProgram; import dark.api.al.coding.TaskRegistry; import dark.assembly.common.armbot.Program; @@ -115,7 +115,7 @@ public class TileEntityEncoder extends TileEntityMachine implements ISidedInvent if (id.equalsIgnoreCase(TileEntityEncoder.PROGRAM_CHANGE)) { - IDeviceTask task = TaskRegistry.getCommand(dis.readUTF()); + IProcessTask task = TaskRegistry.getCommand(dis.readUTF()); task.setPosition(new Vector2(dis.readInt(), dis.readInt())); task.load(PacketManager.readNBTTagCompound(dis)); this.program.setTaskAt(task.getPosition(), task); @@ -163,7 +163,7 @@ public class TileEntityEncoder extends TileEntityMachine implements ISidedInvent } } - public void updateTask(IDeviceTask task) + public void updateTask(IProcessTask task) { if (task != null) {