Major work on ArmBot.

Command/task management system still needs lots of work.
This commit is contained in:
Brian Ricketts 2013-01-09 19:54:07 -06:00
parent ab51a5203d
commit 1fa56d7827
9 changed files with 269 additions and 99 deletions

View file

@ -4,20 +4,24 @@ import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11;
import assemblyline.common.machine.armbot.TileEntityArmbot;
public class ModelArmbot extends ModelBase public class ModelArmbot extends ModelBase
{ {
// fields // fields
ModelRenderer BaseTop; private ModelRenderer BaseTop;
ModelRenderer Base; private ModelRenderer Base;
ModelRenderer ArmMountRight; private ModelRenderer armMountRight;
ModelRenderer ArmMountLeft; private ModelRenderer armMountLeft;
ModelRenderer ArmLower; private ModelRenderer armLower;
ModelRenderer ArmUpper; private ModelRenderer armUpper;
ModelRenderer BaseRotation; private ModelRenderer baseRotation;
ModelRenderer ClampBody; private ModelRenderer clampBody;
ModelRenderer ClampBody2; private ModelRenderer clampBody2;
ModelRenderer ClampClawLower; private ModelRenderer clampClawLower;
ModelRenderer ClampClawLower2; private ModelRenderer clampClawLower2;
public ModelArmbot() public ModelArmbot()
{ {
@ -36,82 +40,141 @@ public class ModelArmbot extends ModelBase
Base.setTextureSize(64, 32); Base.setTextureSize(64, 32);
Base.mirror = true; Base.mirror = true;
setRotation(Base, 0F, 0F, 0F); setRotation(Base, 0F, 0F, 0F);
ArmMountRight = new ModelRenderer(this, 0, 0); armMountRight = new ModelRenderer(this, 0, 0);
ArmMountRight.addBox(-4F, -5F, -1.5F, 2, 5, 3); armMountRight.addBox(-4F, -5F, -1.5F, 2, 5, 3);
ArmMountRight.setRotationPoint(0F, 17F, 0F); armMountRight.setRotationPoint(0F, 17F, 0F);
ArmMountRight.setTextureSize(64, 32); armMountRight.setTextureSize(64, 32);
ArmMountRight.mirror = true; armMountRight.mirror = true;
setRotation(ArmMountRight, 0F, 0F, 0F); setRotation(armMountRight, 0F, 0F, 0F);
ArmMountLeft = new ModelRenderer(this, 0, 0); armMountLeft = new ModelRenderer(this, 0, 0);
ArmMountLeft.addBox(2F, -5F, -1.5F, 2, 5, 3); armMountLeft.addBox(2F, -5F, -1.5F, 2, 5, 3);
ArmMountLeft.setRotationPoint(0F, 17F, 0F); armMountLeft.setRotationPoint(0F, 17F, 0F);
ArmMountLeft.setTextureSize(64, 32); armMountLeft.setTextureSize(64, 32);
ArmMountLeft.mirror = true; armMountLeft.mirror = true;
setRotation(ArmMountLeft, 0F, 0F, 0F); setRotation(armMountLeft, 0F, 0F, 0F);
ArmLower = new ModelRenderer(this, 0, 0); armLower = new ModelRenderer(this, 0, 0);
ArmLower.addBox(-2F, -15F, -2.5F, 4, 16, 5); armLower.addBox(-2F, -15F, -2.5F, 4, 16, 5);
ArmLower.setRotationPoint(0F, 14F, 0F); armLower.setRotationPoint(0F, 14F, 0F);
ArmLower.setTextureSize(64, 32); armLower.setTextureSize(64, 32);
ArmLower.mirror = true; armLower.mirror = true;
setRotation(ArmLower, 0.5235988F, 0F, 0F); setRotation(armLower, 0.5235988F, 0F, 0F);
ArmUpper = new ModelRenderer(this, 0, 0); armUpper = new ModelRenderer(this, 0, 0);
ArmUpper.addBox(-1.5F, -15F, -2F, 3, 16, 4); armUpper.addBox(-1.5F, -15F, -2F, 3, 16, 4);
ArmUpper.setRotationPoint(0F, 2F, -7F); armUpper.setRotationPoint(0F, 2F, -7F);
ArmUpper.setTextureSize(64, 32); armUpper.setTextureSize(64, 32);
ArmUpper.mirror = true; armUpper.mirror = true;
setRotation(ArmUpper, 2.007129F, 0F, 0F); setRotation(armUpper, 2.007129F, 0F, 0F);
BaseRotation = new ModelRenderer(this, 0, 0); baseRotation = new ModelRenderer(this, 0, 0);
BaseRotation.addBox(-4.5F, 0F, -4.5F, 9, 1, 9); baseRotation.addBox(-4.5F, 0F, -4.5F, 9, 1, 9);
BaseRotation.setRotationPoint(0F, 17F, 0F); baseRotation.setRotationPoint(0F, 17F, 0F);
BaseRotation.setTextureSize(64, 32); baseRotation.setTextureSize(64, 32);
BaseRotation.mirror = true; baseRotation.mirror = true;
setRotation(BaseRotation, 0F, 0F, 0F); setRotation(baseRotation, 0F, 0F, 0F);
ClampBody = new ModelRenderer(this, 0, 0); clampBody = new ModelRenderer(this, 0, 0);
ClampBody.addBox(-2F, -17F, -2.5F, 4, 2, 5); clampBody.addBox(-2F, -17F, -2.5F, 4, 2, 5);
ClampBody.setRotationPoint(0F, 2F, -7F); clampBody.setRotationPoint(0F, 2F, -7F);
ClampBody.setTextureSize(64, 32); clampBody.setTextureSize(64, 32);
ClampBody.mirror = true; clampBody.mirror = true;
setRotation(ClampBody, 2.007129F, 0F, 0F); setRotation(clampBody, 2.007129F, 0F, 0F);
ClampBody2 = new ModelRenderer(this, 0, 0); clampBody2 = new ModelRenderer(this, 0, 0);
ClampBody2.addBox(-1.5F, -19F, -1F, 3, 2, 2); clampBody2.addBox(-1.5F, -19F, -1F, 3, 2, 2);
ClampBody2.setRotationPoint(0F, 2F, -7F); clampBody2.setRotationPoint(0F, 2F, -7F);
ClampBody2.setTextureSize(64, 32); clampBody2.setTextureSize(64, 32);
ClampBody2.mirror = true; clampBody2.mirror = true;
setRotation(ClampBody2, 2.007129F, 0F, 0F); setRotation(clampBody2, 2.007129F, 0F, 0F);
ClampClawLower = new ModelRenderer(this, 0, 0); clampClawLower = new ModelRenderer(this, 0, 0);
ClampClawLower.addBox(-2.5F, -5F, -1F, 5, 6, 1); clampClawLower.addBox(-2.5F, -5F, -1F, 5, 6, 1);
ClampClawLower.setRotationPoint(0F, 10F, -23F); clampClawLower.setRotationPoint(0F, 10F, -23F);
ClampClawLower.setTextureSize(64, 32); clampClawLower.setTextureSize(64, 32);
ClampClawLower.mirror = true; clampClawLower.mirror = true;
setRotation(ClampClawLower, 2.007129F, 0F, 0F); setRotation(clampClawLower, 2.007129F, 0F, 0F);
ClampClawLower2 = new ModelRenderer(this, 0, 0); clampClawLower2 = new ModelRenderer(this, 0, 0);
ClampClawLower2.addBox(-2.5F, -5F, 1F, 5, 6, 1); clampClawLower2.addBox(-2.5F, -5F, 1F, 5, 6, 1);
ClampClawLower2.setRotationPoint(0F, 10F, -23F); clampClawLower2.setRotationPoint(0F, 10F, -23F);
ClampClawLower2.setTextureSize(64, 32); clampClawLower2.setTextureSize(64, 32);
ClampClawLower2.mirror = true; clampClawLower2.mirror = true;
setRotation(ClampClawLower2, 2.007129F, 0F, 0F); setRotation(clampClawLower2, 2.007129F, 0F, 0F);
} }
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{ {
super.render(entity, f, f1, f2, f3, f4, f5); super.render(entity, f, f1, f2, f3, f4, f5);
this.setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
this.render(f5); this.render(f5, null);
} }
public void render(float f5) public void render(float f5, TileEntityArmbot armBot)
{ {
// set yaw from tileentity
if (armBot != null)
{
/*armMountRight.setRotationPoint(baseRotation.rotationPointX, armMountRight.rotationPointY, baseRotation.rotationPointX);
armMountLeft.setRotationPoint(baseRotation.rotationPointX, armMountLeft.rotationPointY, baseRotation.rotationPointX);
armLower.setRotationPoint(baseRotation.rotationPointX, armLower.rotationPointY, baseRotation.rotationPointX);
armUpper.setRotationPoint(baseRotation.rotationPointX, armUpper.rotationPointY, baseRotation.rotationPointX);
baseRotation.setRotationPoint(baseRotation.rotationPointX, baseRotation.rotationPointY, baseRotation.rotationPointX);
clampBody.setRotationPoint(baseRotation.rotationPointX, clampBody.rotationPointY, baseRotation.rotationPointX);
clampBody2.setRotationPoint(baseRotation.rotationPointX, clampBody2.rotationPointY, baseRotation.rotationPointX);
clampClawLower.setRotationPoint(baseRotation.rotationPointX, clampClawLower.rotationPointY, baseRotation.rotationPointX);
clampClawLower2.setRotationPoint(baseRotation.rotationPointX, clampClawLower2.rotationPointY, baseRotation.rotationPointX);
armMountRight.rotateAngleY = armBot.rotationYaw;
armMountLeft.rotateAngleY = armBot.rotationYaw;
armLower.rotateAngleY = armBot.rotationYaw;
armUpper.rotateAngleY = armBot.rotationYaw;
baseRotation.rotateAngleY = armBot.rotationYaw;
clampBody.rotateAngleY = armBot.rotationYaw;
clampBody2.rotateAngleY = armBot.rotationYaw;
clampClawLower.rotateAngleY = armBot.rotationYaw;
clampClawLower2.rotateAngleY = armBot.rotationYaw;*/
BaseTop.render(f5); BaseTop.render(f5);
Base.render(f5); Base.render(f5);
ArmMountRight.render(f5); GL11.glPushMatrix();
ArmMountLeft.render(f5); GL11.glRotatef((float) (armBot.rotationYaw * (180f / Math.PI)), 0, 1, 0);
ArmLower.render(f5); armMountRight.render(f5);
ArmUpper.render(f5); armMountLeft.render(f5);
BaseRotation.render(f5); armLower.render(f5);
ClampBody.render(f5); armUpper.render(f5);
ClampBody2.render(f5); baseRotation.render(f5);
ClampClawLower.render(f5); clampBody.render(f5);
ClampClawLower2.render(f5); clampBody2.render(f5);
clampClawLower.render(f5);
clampClawLower2.render(f5);
GL11.glPopMatrix();
}
else
{
/*armMountRight.setRotationPoint(0F, 17F, 0F);
setRotation(armMountRight, 0F, 0F, 0F);
armMountLeft.setRotationPoint(0F, 17F, 0F);
setRotation(armMountLeft, 0F, 0F, 0F);
armLower.setRotationPoint(0F, 14F, 0F);
setRotation(armLower, 0.5235988F, 0F, 0F);
armUpper.setRotationPoint(0F, 2F, -7F);
setRotation(armUpper, 2.007129F, 0F, 0F);
baseRotation.setRotationPoint(0F, 17F, 0F);
setRotation(baseRotation, 0F, 0F, 0F);
clampBody.setRotationPoint(0F, 2F, -7F);
setRotation(clampBody, 2.007129F, 0F, 0F);
clampBody2.setRotationPoint(0F, 2F, -7F);
setRotation(clampBody2, 2.007129F, 0F, 0F);
clampClawLower.setRotationPoint(0F, 10F, -23F);
setRotation(clampClawLower, 2.007129F, 0F, 0F);
clampClawLower2.setRotationPoint(0F, 10F, -23F);
setRotation(clampClawLower2, 2.007129F, 0F, 0F);*/
BaseTop.render(f5);
Base.render(f5);
armMountRight.render(f5);
armMountLeft.render(f5);
armLower.render(f5);
armUpper.render(f5);
baseRotation.render(f5);
clampBody.render(f5);
clampBody2.render(f5);
clampClawLower.render(f5);
clampClawLower2.render(f5);
}
} }
private void setRotation(ModelRenderer model, float x, float y, float z) private void setRotation(ModelRenderer model, float x, float y, float z)

View file

@ -71,7 +71,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
GL11.glScalef(0.7f, 0.7f, 0.7f); GL11.glScalef(0.7f, 0.7f, 0.7f);
GL11.glRotatef(180f, 0f, 0f, 1f); GL11.glRotatef(180f, 0f, 0f, 1f);
GL11.glRotatef(-90f, 0f, 1f, 0f); GL11.glRotatef(-90f, 0f, 1f, 0f);
RenderArmbot.MODEL.render(0.0625F); RenderArmbot.MODEL.render(0.0625F, null);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
} }

View file

@ -7,6 +7,7 @@ import org.lwjgl.opengl.GL11;
import assemblyline.client.model.ModelArmbot; import assemblyline.client.model.ModelArmbot;
import assemblyline.common.AssemblyLine; import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.armbot.TileEntityArmbot;
public class RenderArmbot extends TileEntitySpecialRenderer public class RenderArmbot extends TileEntitySpecialRenderer
{ {
@ -15,13 +16,16 @@ public class RenderArmbot extends TileEntitySpecialRenderer
@Override @Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8) public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
{
if (tileEntity instanceof TileEntityArmbot)
{ {
this.bindTextureByName(AssemblyLine.TEXTURE_PATH + TEXTURE); this.bindTextureByName(AssemblyLine.TEXTURE_PATH + TEXTURE);
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
GL11.glScalef(1.0F, -1F, -1F); GL11.glScalef(1.0F, -1F, -1F);
MODEL.render(0.0625f); MODEL.render(0.0625f, (TileEntityArmbot) tileEntity);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
}
} }

View file

@ -12,6 +12,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.INetworkManager; import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
@ -21,14 +23,19 @@ import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.TranslationHelper; import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.multiblock.IMultiBlock; import universalelectricity.prefab.multiblock.IMultiBlock;
import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager;
import assemblyline.common.AssemblyLine; import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.TileEntityAssemblyNetwork; import assemblyline.common.machine.TileEntityAssemblyNetwork;
import assemblyline.common.machine.command.Command;
import assemblyline.common.machine.command.CommandIdle; import assemblyline.common.machine.command.CommandIdle;
import assemblyline.common.machine.command.CommandManager; import assemblyline.common.machine.command.CommandManager;
import assemblyline.common.machine.encoder.ItemDisk; import assemblyline.common.machine.encoder.ItemDisk;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMultiBlock, IInventory, IPacketReceiver, IJouleStorage public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMultiBlock, IInventory, IPacketReceiver, IJouleStorage
{ {
/** /**
@ -72,8 +79,21 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
entity.motionZ = 0; entity.motionZ = 0;
} }
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
this.taskManager.onUpdate(); this.taskManager.onUpdate();
if (!this.taskManager.hasTasks())
{
this.taskManager.addTask(this, new CommandIdle(this));
} }
if (rotationPitch < 0) rotationPitch += (float) (Math.PI * 2);
if (rotationPitch >= Math.PI * 2) rotationPitch -= (float) (Math.PI * 2);
if (rotationYaw < 0) rotationYaw += (float) (Math.PI * 2);
if (rotationYaw >= Math.PI * 2) rotationYaw -= (float) (Math.PI * 2);
}
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) //this makes it look smoother on the client, since the client seems to not be in-sync power-wise
this.taskManager.onUpdate();
} }
@Override @Override
@ -82,6 +102,27 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
return 120; return 120;
} }
@Override
public Packet getDescriptionPacket()
{
NBTTagCompound nbt = new NBTTagCompound();
writeToNBT(nbt);
Packet132TileEntityData data = new Packet132TileEntityData(xCoord, yCoord, zCoord, 0, nbt);
return data;
}
@Override
public void onDataPacket(INetworkManager netManager, Packet132TileEntityData packet)
{
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
{
xCoord = packet.xPosition;
yCoord = packet.yPosition;
zCoord = packet.zPosition;
readFromNBT(packet.customParam1);
}
}
/** /**
* Data * Data
*/ */
@ -217,6 +258,9 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4); this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4);
} }
} }
rotationYaw = nbt.getFloat("yaw");
rotationPitch = nbt.getFloat("pitch");
} }
/** /**
@ -238,6 +282,8 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
} }
} }
nbt.setTag("Items", var2); nbt.setTag("Items", var2);
nbt.setFloat("yaw", rotationYaw);
nbt.setFloat("pitch", rotationPitch);
} }
@Override @Override
@ -265,7 +311,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
if (containingStack != null) if (containingStack != null)
{ {
if (!this.worldObj.isRemote) if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
{ {
EntityItem dropStack = new EntityItem(this.worldObj, player.posX, player.posY, player.posZ, containingStack); EntityItem dropStack = new EntityItem(this.worldObj, player.posX, player.posY, player.posZ, containingStack);
dropStack.delayBeforeCanPickup = 0; dropStack.delayBeforeCanPickup = 0;
@ -273,6 +319,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
} }
this.setInventorySlotContents(0, null); this.setInventorySlotContents(0, null);
onInventoryChanged();
return true; return true;
} }
else else
@ -282,6 +329,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
if (player.getCurrentEquippedItem().getItem() instanceof ItemDisk) if (player.getCurrentEquippedItem().getItem() instanceof ItemDisk)
{ {
this.setInventorySlotContents(0, player.getCurrentEquippedItem()); this.setInventorySlotContents(0, player.getCurrentEquippedItem());
onInventoryChanged();
player.inventory.setInventorySlotContents(player.inventory.currentItem, null); player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
return true; return true;
} }
@ -291,6 +339,34 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
return false; return false;
} }
@Override
public void onInventoryChanged()
{
super.onInventoryChanged();
ItemStack disk = this.getStackInSlot(0);
if (disk != null)
{
taskManager = new CommandManager();
for (String commandName : ItemDisk.getCommands(disk))
{
try
{
//TODO: HOW THE CRAP AM I SUPPOSED TO ADD A COMMAND?!
//taskManager.addTask(this, (Command) Command.getCommand(commandName).getConstructor(TileEntityArmbot.class, String[].class).newInstance(this, new String[] {}));
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
else
{
taskManager = new CommandManager();
taskManager.addTask(this, new CommandIdle(this));
}
}
@Override @Override
public void onCreate(Vector3 placedPosition) public void onCreate(Vector3 placedPosition)
{ {

View file

@ -34,7 +34,7 @@ public abstract class Command
public static Class<? extends Command> getCommand(String command) public static Class<? extends Command> getCommand(String command)
{ {
return COMMANDS.get(command); return COMMANDS.get(command.toLowerCase());
} }
/** /**
@ -82,6 +82,6 @@ public abstract class Command
*/ */
public int getTickInterval() public int getTickInterval()
{ {
return 0; return 1;
} }
} }

View file

@ -18,17 +18,29 @@ public class CommandIdle extends Command
/** /**
* Move the arm rotation to idle position if the machine is not idling * Move the arm rotation to idle position if the machine is not idling
*/ */
if (this.tileEntity.rotationPitch != IDLE_ROTATION_PITCH && this.tileEntity.rotationYaw != IDLE_ROTATION_YAW) if (Math.abs(this.tileEntity.rotationPitch - IDLE_ROTATION_PITCH) > 0.001 || Math.abs(this.tileEntity.rotationYaw - IDLE_ROTATION_YAW) > 0.001)
{ {
if (Math.abs(IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) > 0.125)
this.tileEntity.rotationPitch += (IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) * 0.05; this.tileEntity.rotationPitch += (IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) * 0.05;
else
this.tileEntity.rotationPitch += Math.signum(IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) * (0.125 * 0.05);
if (Math.abs(this.tileEntity.rotationPitch - IDLE_ROTATION_PITCH) < 0.0125)
this.tileEntity.rotationPitch = IDLE_ROTATION_PITCH;
if (Math.abs(IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) > 0.125)
this.tileEntity.rotationYaw += (IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) * 0.05; this.tileEntity.rotationYaw += (IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) * 0.05;
else
this.tileEntity.rotationYaw += Math.signum(IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) * (0.125 * 0.05);
if (Math.abs(this.tileEntity.rotationYaw - IDLE_ROTATION_YAW) < 0.0125)
this.tileEntity.rotationYaw = IDLE_ROTATION_YAW;
return true; return true;
} }
/** /**
* Randomly move the arm to simulate life in the arm if the arm is powered * Randomly move the arm to simulate life in the arm if the arm is powered
*/ */
this.tileEntity.rotationYaw *= 0.98 * this.world.rand.nextFloat(); //this.tileEntity.rotationYaw *= 0.98 * this.world.rand.nextFloat();
return false; return false;
} }

View file

@ -70,4 +70,9 @@ public class CommandManager
{ {
return !tasks.isEmpty(); return !tasks.isEmpty();
} }
public List<Command> getCommands()
{
return tasks;
}
} }

View file

@ -15,10 +15,10 @@ public class CommandRotate extends Command
{ {
float targetRotation = 0; float targetRotation = 0;
public CommandRotate(TileEntityArmbot arm, String[] parameters) public CommandRotate(TileEntityArmbot arm, String...parameters)
{ {
super(arm, parameters); super(arm, parameters);
this.targetRotation = arm.rotationPitch + 90; this.targetRotation = arm.rotationYaw + (float) (Math.PI / 2);
} }
@Override @Override
@ -26,11 +26,18 @@ public class CommandRotate extends Command
{ {
super.doTask(); super.doTask();
if (this.tileEntity.rotationPitch < this.targetRotation) if (this.tileEntity.rotationYaw != this.targetRotation)
{ {
this.tileEntity.rotationPitch += 0.01; if (Math.abs(this.targetRotation - this.tileEntity.rotationYaw) > 0.125)
this.tileEntity.rotationYaw += (this.targetRotation - this.tileEntity.rotationYaw) * 0.05;
else
this.tileEntity.rotationYaw += Math.signum(this.targetRotation - this.tileEntity.rotationYaw) * (0.125 * 0.05);
if (Math.abs(this.tileEntity.rotationYaw - this.targetRotation) < 0.0125)
this.tileEntity.rotationYaw = this.targetRotation;
return true; return true;
} }
if (ticks < 80)
return true;
return false; return false;
} }

View file

@ -36,7 +36,10 @@ public class ItemDisk extends Item
if (commands.size() > 0) if (commands.size() > 0)
{ {
list.add(commands.size() + " command(s)"); if (commands.size() == 1)
list.add(commands.size() + " command");
else
list.add(commands.size() + " commands");
} }
else else
{ {