From 1fa56d7827df388a439ac5f819e8b9d4eb922636 Mon Sep 17 00:00:00 2001 From: Brian Ricketts Date: Wed, 9 Jan 2013 19:54:07 -0600 Subject: [PATCH] Major work on ArmBot. Command/task management system still needs lots of work. --- .../client/model/ModelArmbot.java | 219 +++++++++++------- .../client/render/BlockRenderingHandler.java | 2 +- .../client/render/RenderArmbot.java | 16 +- .../machine/armbot/TileEntityArmbot.java | 82 ++++++- .../common/machine/command/Command.java | 4 +- .../common/machine/command/CommandIdle.java | 20 +- .../machine/command/CommandManager.java | 5 + .../common/machine/command/CommandRotate.java | 15 +- .../common/machine/encoder/ItemDisk.java | 5 +- 9 files changed, 269 insertions(+), 99 deletions(-) diff --git a/src/minecraft/assemblyline/client/model/ModelArmbot.java b/src/minecraft/assemblyline/client/model/ModelArmbot.java index f70dc783..fe288f55 100644 --- a/src/minecraft/assemblyline/client/model/ModelArmbot.java +++ b/src/minecraft/assemblyline/client/model/ModelArmbot.java @@ -4,20 +4,24 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; +import org.lwjgl.opengl.GL11; + +import assemblyline.common.machine.armbot.TileEntityArmbot; + public class ModelArmbot extends ModelBase { // fields - ModelRenderer BaseTop; - ModelRenderer Base; - ModelRenderer ArmMountRight; - ModelRenderer ArmMountLeft; - ModelRenderer ArmLower; - ModelRenderer ArmUpper; - ModelRenderer BaseRotation; - ModelRenderer ClampBody; - ModelRenderer ClampBody2; - ModelRenderer ClampClawLower; - ModelRenderer ClampClawLower2; + private ModelRenderer BaseTop; + private ModelRenderer Base; + private ModelRenderer armMountRight; + private ModelRenderer armMountLeft; + private ModelRenderer armLower; + private ModelRenderer armUpper; + private ModelRenderer baseRotation; + private ModelRenderer clampBody; + private ModelRenderer clampBody2; + private ModelRenderer clampClawLower; + private ModelRenderer clampClawLower2; public ModelArmbot() { @@ -36,82 +40,141 @@ public class ModelArmbot extends ModelBase Base.setTextureSize(64, 32); Base.mirror = true; setRotation(Base, 0F, 0F, 0F); - ArmMountRight = new ModelRenderer(this, 0, 0); - ArmMountRight.addBox(-4F, -5F, -1.5F, 2, 5, 3); - ArmMountRight.setRotationPoint(0F, 17F, 0F); - ArmMountRight.setTextureSize(64, 32); - ArmMountRight.mirror = true; - setRotation(ArmMountRight, 0F, 0F, 0F); - ArmMountLeft = new ModelRenderer(this, 0, 0); - ArmMountLeft.addBox(2F, -5F, -1.5F, 2, 5, 3); - ArmMountLeft.setRotationPoint(0F, 17F, 0F); - ArmMountLeft.setTextureSize(64, 32); - ArmMountLeft.mirror = true; - setRotation(ArmMountLeft, 0F, 0F, 0F); - ArmLower = new ModelRenderer(this, 0, 0); - ArmLower.addBox(-2F, -15F, -2.5F, 4, 16, 5); - ArmLower.setRotationPoint(0F, 14F, 0F); - ArmLower.setTextureSize(64, 32); - ArmLower.mirror = true; - setRotation(ArmLower, 0.5235988F, 0F, 0F); - ArmUpper = new ModelRenderer(this, 0, 0); - ArmUpper.addBox(-1.5F, -15F, -2F, 3, 16, 4); - ArmUpper.setRotationPoint(0F, 2F, -7F); - ArmUpper.setTextureSize(64, 32); - ArmUpper.mirror = true; - setRotation(ArmUpper, 2.007129F, 0F, 0F); - BaseRotation = new ModelRenderer(this, 0, 0); - BaseRotation.addBox(-4.5F, 0F, -4.5F, 9, 1, 9); - BaseRotation.setRotationPoint(0F, 17F, 0F); - BaseRotation.setTextureSize(64, 32); - BaseRotation.mirror = true; - setRotation(BaseRotation, 0F, 0F, 0F); - ClampBody = new ModelRenderer(this, 0, 0); - ClampBody.addBox(-2F, -17F, -2.5F, 4, 2, 5); - ClampBody.setRotationPoint(0F, 2F, -7F); - ClampBody.setTextureSize(64, 32); - ClampBody.mirror = true; - setRotation(ClampBody, 2.007129F, 0F, 0F); - ClampBody2 = new ModelRenderer(this, 0, 0); - ClampBody2.addBox(-1.5F, -19F, -1F, 3, 2, 2); - ClampBody2.setRotationPoint(0F, 2F, -7F); - ClampBody2.setTextureSize(64, 32); - ClampBody2.mirror = true; - setRotation(ClampBody2, 2.007129F, 0F, 0F); - ClampClawLower = new ModelRenderer(this, 0, 0); - ClampClawLower.addBox(-2.5F, -5F, -1F, 5, 6, 1); - ClampClawLower.setRotationPoint(0F, 10F, -23F); - ClampClawLower.setTextureSize(64, 32); - ClampClawLower.mirror = true; - setRotation(ClampClawLower, 2.007129F, 0F, 0F); - ClampClawLower2 = new ModelRenderer(this, 0, 0); - ClampClawLower2.addBox(-2.5F, -5F, 1F, 5, 6, 1); - ClampClawLower2.setRotationPoint(0F, 10F, -23F); - ClampClawLower2.setTextureSize(64, 32); - ClampClawLower2.mirror = true; - setRotation(ClampClawLower2, 2.007129F, 0F, 0F); + armMountRight = new ModelRenderer(this, 0, 0); + armMountRight.addBox(-4F, -5F, -1.5F, 2, 5, 3); + armMountRight.setRotationPoint(0F, 17F, 0F); + armMountRight.setTextureSize(64, 32); + armMountRight.mirror = true; + setRotation(armMountRight, 0F, 0F, 0F); + armMountLeft = new ModelRenderer(this, 0, 0); + armMountLeft.addBox(2F, -5F, -1.5F, 2, 5, 3); + armMountLeft.setRotationPoint(0F, 17F, 0F); + armMountLeft.setTextureSize(64, 32); + armMountLeft.mirror = true; + setRotation(armMountLeft, 0F, 0F, 0F); + armLower = new ModelRenderer(this, 0, 0); + armLower.addBox(-2F, -15F, -2.5F, 4, 16, 5); + armLower.setRotationPoint(0F, 14F, 0F); + armLower.setTextureSize(64, 32); + armLower.mirror = true; + setRotation(armLower, 0.5235988F, 0F, 0F); + armUpper = new ModelRenderer(this, 0, 0); + armUpper.addBox(-1.5F, -15F, -2F, 3, 16, 4); + armUpper.setRotationPoint(0F, 2F, -7F); + armUpper.setTextureSize(64, 32); + armUpper.mirror = true; + setRotation(armUpper, 2.007129F, 0F, 0F); + baseRotation = new ModelRenderer(this, 0, 0); + baseRotation.addBox(-4.5F, 0F, -4.5F, 9, 1, 9); + baseRotation.setRotationPoint(0F, 17F, 0F); + baseRotation.setTextureSize(64, 32); + baseRotation.mirror = true; + setRotation(baseRotation, 0F, 0F, 0F); + clampBody = new ModelRenderer(this, 0, 0); + clampBody.addBox(-2F, -17F, -2.5F, 4, 2, 5); + clampBody.setRotationPoint(0F, 2F, -7F); + clampBody.setTextureSize(64, 32); + clampBody.mirror = true; + setRotation(clampBody, 2.007129F, 0F, 0F); + clampBody2 = new ModelRenderer(this, 0, 0); + clampBody2.addBox(-1.5F, -19F, -1F, 3, 2, 2); + clampBody2.setRotationPoint(0F, 2F, -7F); + clampBody2.setTextureSize(64, 32); + clampBody2.mirror = true; + setRotation(clampBody2, 2.007129F, 0F, 0F); + clampClawLower = new ModelRenderer(this, 0, 0); + clampClawLower.addBox(-2.5F, -5F, -1F, 5, 6, 1); + clampClawLower.setRotationPoint(0F, 10F, -23F); + clampClawLower.setTextureSize(64, 32); + clampClawLower.mirror = true; + setRotation(clampClawLower, 2.007129F, 0F, 0F); + clampClawLower2 = new ModelRenderer(this, 0, 0); + clampClawLower2.addBox(-2.5F, -5F, 1F, 5, 6, 1); + clampClawLower2.setRotationPoint(0F, 10F, -23F); + clampClawLower2.setTextureSize(64, 32); + clampClawLower2.mirror = true; + setRotation(clampClawLower2, 2.007129F, 0F, 0F); } 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); 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) { - 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); + + // 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); + Base.render(f5); + GL11.glPushMatrix(); + GL11.glRotatef((float) (armBot.rotationYaw * (180f / Math.PI)), 0, 1, 0); + 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); + 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) diff --git a/src/minecraft/assemblyline/client/render/BlockRenderingHandler.java b/src/minecraft/assemblyline/client/render/BlockRenderingHandler.java index 13ac0733..8a29874c 100644 --- a/src/minecraft/assemblyline/client/render/BlockRenderingHandler.java +++ b/src/minecraft/assemblyline/client/render/BlockRenderingHandler.java @@ -71,7 +71,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler GL11.glScalef(0.7f, 0.7f, 0.7f); GL11.glRotatef(180f, 0f, 0f, 1f); GL11.glRotatef(-90f, 0f, 1f, 0f); - RenderArmbot.MODEL.render(0.0625F); + RenderArmbot.MODEL.render(0.0625F, null); GL11.glPopMatrix(); } } diff --git a/src/minecraft/assemblyline/client/render/RenderArmbot.java b/src/minecraft/assemblyline/client/render/RenderArmbot.java index 56613a4f..a9790290 100644 --- a/src/minecraft/assemblyline/client/render/RenderArmbot.java +++ b/src/minecraft/assemblyline/client/render/RenderArmbot.java @@ -7,6 +7,7 @@ import org.lwjgl.opengl.GL11; import assemblyline.client.model.ModelArmbot; import assemblyline.common.AssemblyLine; +import assemblyline.common.machine.armbot.TileEntityArmbot; public class RenderArmbot extends TileEntitySpecialRenderer { @@ -16,12 +17,15 @@ public class RenderArmbot extends TileEntitySpecialRenderer @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8) { - this.bindTextureByName(AssemblyLine.TEXTURE_PATH + TEXTURE); - GL11.glPushMatrix(); - GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - GL11.glScalef(1.0F, -1F, -1F); - MODEL.render(0.0625f); - GL11.glPopMatrix(); + if (tileEntity instanceof TileEntityArmbot) + { + this.bindTextureByName(AssemblyLine.TEXTURE_PATH + TEXTURE); + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + MODEL.render(0.0625f, (TileEntityArmbot) tileEntity); + GL11.glPopMatrix(); + } } } \ No newline at end of file diff --git a/src/minecraft/assemblyline/common/machine/armbot/TileEntityArmbot.java b/src/minecraft/assemblyline/common/machine/armbot/TileEntityArmbot.java index f63fd8e4..32e25aff 100644 --- a/src/minecraft/assemblyline/common/machine/armbot/TileEntityArmbot.java +++ b/src/minecraft/assemblyline/common/machine/armbot/TileEntityArmbot.java @@ -12,6 +12,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; 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.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; @@ -21,14 +23,19 @@ import universalelectricity.core.vector.Vector3; import universalelectricity.prefab.TranslationHelper; import universalelectricity.prefab.multiblock.IMultiBlock; import universalelectricity.prefab.network.IPacketReceiver; +import universalelectricity.prefab.network.PacketManager; import assemblyline.common.AssemblyLine; import assemblyline.common.machine.TileEntityAssemblyNetwork; +import assemblyline.common.machine.command.Command; import assemblyline.common.machine.command.CommandIdle; import assemblyline.common.machine.command.CommandManager; import assemblyline.common.machine.encoder.ItemDisk; 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 { /** @@ -72,8 +79,21 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult entity.motionZ = 0; } - this.taskManager.onUpdate(); + if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) + 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 @@ -81,6 +101,27 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult { 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 @@ -88,7 +129,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult @Override public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream) { - + } /** @@ -217,6 +258,9 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult 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.setFloat("yaw", rotationYaw); + nbt.setFloat("pitch", rotationPitch); } @Override @@ -265,7 +311,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult 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); dropStack.delayBeforeCanPickup = 0; @@ -273,6 +319,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult } this.setInventorySlotContents(0, null); + onInventoryChanged(); return true; } else @@ -282,6 +329,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult if (player.getCurrentEquippedItem().getItem() instanceof ItemDisk) { this.setInventorySlotContents(0, player.getCurrentEquippedItem()); + onInventoryChanged(); player.inventory.setInventorySlotContents(player.inventory.currentItem, null); return true; } @@ -291,6 +339,34 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult 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 public void onCreate(Vector3 placedPosition) { diff --git a/src/minecraft/assemblyline/common/machine/command/Command.java b/src/minecraft/assemblyline/common/machine/command/Command.java index a50c5b5d..6bb244eb 100644 --- a/src/minecraft/assemblyline/common/machine/command/Command.java +++ b/src/minecraft/assemblyline/common/machine/command/Command.java @@ -34,7 +34,7 @@ public abstract class Command public static Class getCommand(String command) { - return COMMANDS.get(command); + return COMMANDS.get(command.toLowerCase()); } /** @@ -82,6 +82,6 @@ public abstract class Command */ public int getTickInterval() { - return 0; + return 1; } } diff --git a/src/minecraft/assemblyline/common/machine/command/CommandIdle.java b/src/minecraft/assemblyline/common/machine/command/CommandIdle.java index 1a920710..5f790179 100644 --- a/src/minecraft/assemblyline/common/machine/command/CommandIdle.java +++ b/src/minecraft/assemblyline/common/machine/command/CommandIdle.java @@ -18,17 +18,29 @@ public class CommandIdle extends Command /** * 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) { - this.tileEntity.rotationPitch += (IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) * 0.05; - this.tileEntity.rotationYaw += (IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) * 0.05; + if (Math.abs(IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) > 0.125) + 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; + 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; } /** * 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; } diff --git a/src/minecraft/assemblyline/common/machine/command/CommandManager.java b/src/minecraft/assemblyline/common/machine/command/CommandManager.java index a4830e9c..949b5ad3 100644 --- a/src/minecraft/assemblyline/common/machine/command/CommandManager.java +++ b/src/minecraft/assemblyline/common/machine/command/CommandManager.java @@ -70,4 +70,9 @@ public class CommandManager { return !tasks.isEmpty(); } + + public List getCommands() + { + return tasks; + } } diff --git a/src/minecraft/assemblyline/common/machine/command/CommandRotate.java b/src/minecraft/assemblyline/common/machine/command/CommandRotate.java index c3eecd73..2130a541 100644 --- a/src/minecraft/assemblyline/common/machine/command/CommandRotate.java +++ b/src/minecraft/assemblyline/common/machine/command/CommandRotate.java @@ -15,10 +15,10 @@ public class CommandRotate extends Command { float targetRotation = 0; - public CommandRotate(TileEntityArmbot arm, String[] parameters) + public CommandRotate(TileEntityArmbot arm, String...parameters) { super(arm, parameters); - this.targetRotation = arm.rotationPitch + 90; + this.targetRotation = arm.rotationYaw + (float) (Math.PI / 2); } @Override @@ -26,11 +26,18 @@ public class CommandRotate extends Command { 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; } + if (ticks < 80) + return true; return false; } diff --git a/src/minecraft/assemblyline/common/machine/encoder/ItemDisk.java b/src/minecraft/assemblyline/common/machine/encoder/ItemDisk.java index cac61bf5..22e32eee 100644 --- a/src/minecraft/assemblyline/common/machine/encoder/ItemDisk.java +++ b/src/minecraft/assemblyline/common/machine/encoder/ItemDisk.java @@ -36,7 +36,10 @@ public class ItemDisk extends Item 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 {