From 7a048652ac741cda3240b2327256d4152eb2dc37 Mon Sep 17 00:00:00 2001 From: Brian Ricketts Date: Tue, 15 Jan 2013 03:40:17 -0600 Subject: [PATCH] Tried fixing ArmBot again... --- .../machine/armbot/TileEntityArmbot.java | 27 ++++++++----------- .../common/machine/command/Command.java | 15 +++++++++-- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/minecraft/assemblyline/common/machine/armbot/TileEntityArmbot.java b/src/minecraft/assemblyline/common/machine/armbot/TileEntityArmbot.java index 037d6fd04..cde5f82b1 100644 --- a/src/minecraft/assemblyline/common/machine/armbot/TileEntityArmbot.java +++ b/src/minecraft/assemblyline/common/machine/armbot/TileEntityArmbot.java @@ -59,7 +59,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult public double wattsReceived = 0; private int playerUsing = 0; - + private int computersAttached = 0; /** @@ -119,8 +119,6 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult if (this.disk == null && this.computersAttached == 0) { - this.commandManager.clear(); - if (this.grabbedEntities.size() > 0) { this.commandManager.addCommand(this, CommandDrop.class); @@ -128,8 +126,12 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult else { if (!this.commandManager.hasTasks()) + { if (Math.abs(this.rotationYaw - CommandReturn.IDLE_ROTATION_YAW) > 0.01) + { this.commandManager.addCommand(this, CommandReturn.class); + } + } } this.commandManager.setCurrentTask(0); @@ -457,6 +459,10 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult } } } + else + { + this.commandManager.clear(); + } } @Override @@ -500,7 +506,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult { double angle = (Double) arguments[0]; this.commandManager.addCommand(this, CommandRotate.class, new String[] { Double.toString(angle) }); - while(this.commandManager.hasTasks()) + while (this.commandManager.hasTasks()) { Thread.sleep(1); } @@ -526,10 +532,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult double angle = (Double) arguments[0]; double diff = angle - this.rotationYaw; this.commandManager.addCommand(this, CommandRotate.class, new String[] { Double.toString(diff) }); - while(this.commandManager.hasTasks()) - { - Thread.sleep(1); - } + while (this.commandManager.hasTasks()); } catch (Exception ex) { @@ -546,19 +549,11 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult case 2: // grab: grabs an item { this.commandManager.addCommand(this, CommandGrab.class); - while(this.commandManager.hasTasks()) - { - Thread.sleep(1); - } break; } case 3: // drop: drops an item { this.commandManager.addCommand(this, CommandDrop.class); - while(this.commandManager.hasTasks()) - { - Thread.sleep(1); - } break; } case 4: // reset: calls the RETURN command diff --git a/src/minecraft/assemblyline/common/machine/command/Command.java b/src/minecraft/assemblyline/common/machine/command/Command.java index 184e776dd..854dd414f 100644 --- a/src/minecraft/assemblyline/common/machine/command/Command.java +++ b/src/minecraft/assemblyline/common/machine/command/Command.java @@ -3,6 +3,8 @@ package assemblyline.common.machine.command; import java.util.HashMap; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; import net.minecraft.world.World; import assemblyline.common.machine.armbot.TileEntityArmbot; @@ -121,7 +123,7 @@ public abstract class Command } catch (Exception e) { - + } } @@ -130,6 +132,15 @@ public abstract class Command public void writeToNBT(NBTTagCompound taskCompound) { - + NBTTagCompound tileEntityNBT = new NBTTagCompound(); + this.tileEntity.writeToNBT(tileEntityNBT); + taskCompound.setCompoundTag("tileEntity", tileEntityNBT); + taskCompound.setInteger("ticks", this.ticks); + NBTTagList parList = new NBTTagList(); + for (String parameter : this.parameters) + { + parList.appendTag(new NBTTagString(parameter)); + } + taskCompound.setTag("parameters", parList); } }