From f0dcceddb7bc4796227aacb956bf8b7871c52746 Mon Sep 17 00:00:00 2001 From: Henry Mao Date: Tue, 8 Jan 2013 19:19:47 +0800 Subject: [PATCH] Improved Idle Command --- buildnumber.txt | 2 +- obf.rgs | 9 ++++ .../common/block/BlockEncoder2.java | 43 ------------------- .../common/machine/TileEntityManipulator.java | 2 - .../common/machine/armbot/Command.java | 3 ++ .../common/machine/armbot/CommandIdle.java | 17 +++++++- .../machine/crafter/TileEntityArmbot.java | 8 +++- 7 files changed, 35 insertions(+), 49 deletions(-) create mode 100644 obf.rgs delete mode 100644 src/minecraft/assemblyline/common/block/BlockEncoder2.java diff --git a/buildnumber.txt b/buildnumber.txt index 0e91b872..dee6ece8 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -44 +46 diff --git a/obf.rgs b/obf.rgs new file mode 100644 index 00000000..edb8d86b --- /dev/null +++ b/obf.rgs @@ -0,0 +1,9 @@ + +# Ignore all classes +.class ** + +# Except a specific class +!class assemblyline/** + +.option Annotations +.option Trim \ No newline at end of file diff --git a/src/minecraft/assemblyline/common/block/BlockEncoder2.java b/src/minecraft/assemblyline/common/block/BlockEncoder2.java deleted file mode 100644 index 03abbe63..00000000 --- a/src/minecraft/assemblyline/common/block/BlockEncoder2.java +++ /dev/null @@ -1,43 +0,0 @@ -package assemblyline.common.block; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; -import universalelectricity.prefab.UETab; - -public class BlockEncoder2 extends Block -{ - public BlockEncoder2(int par1) - { - super(par1, Material.wood); - this.blockIndexInTexture = 59; - this.setBlockName("engineerTable"); - this.setCreativeTab(UETab.INSTANCE); - } - - /** - * Returns the block texture based on the side being looked at. Args: side - */ - public int getBlockTextureFromSide(int par1) - { - return par1 == 1 ? this.blockIndexInTexture - 16 : (par1 == 0 ? Block.planks.getBlockTextureFromSide(0) : (par1 != 2 && par1 != 4 ? this.blockIndexInTexture : this.blockIndexInTexture + 1)); - } - - /** - * Called upon block activation (right click on the block.) - */ - public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) - { - if (par1World.isRemote) - { - return true; - } - else - { - par5EntityPlayer.displayGUIWorkbench(par2, par3, par4); - return true; - } - } - -} diff --git a/src/minecraft/assemblyline/common/machine/TileEntityManipulator.java b/src/minecraft/assemblyline/common/machine/TileEntityManipulator.java index 3de2cb78..df840e3f 100644 --- a/src/minecraft/assemblyline/common/machine/TileEntityManipulator.java +++ b/src/minecraft/assemblyline/common/machine/TileEntityManipulator.java @@ -16,9 +16,7 @@ import universalelectricity.prefab.implement.IRedstoneReceptor; import universalelectricity.prefab.network.PacketManager; import assemblyline.api.IManipulator; import assemblyline.common.machine.imprinter.TileEntityFilterable; -import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.relauncher.Side; public class TileEntityManipulator extends TileEntityFilterable implements IRedstoneReceptor, IManipulator { diff --git a/src/minecraft/assemblyline/common/machine/armbot/Command.java b/src/minecraft/assemblyline/common/machine/armbot/Command.java index c1cc4db8..16669b54 100644 --- a/src/minecraft/assemblyline/common/machine/armbot/Command.java +++ b/src/minecraft/assemblyline/common/machine/armbot/Command.java @@ -2,6 +2,7 @@ package assemblyline.common.machine.armbot; import java.util.HashMap; +import net.minecraft.world.World; import assemblyline.common.machine.crafter.TileEntityArmbot; /** @@ -35,11 +36,13 @@ public abstract class Command } protected int ticks; + protected World world; protected TileEntityArmbot tileEntity; public Command(TileEntityArmbot arm) { this.tileEntity = arm; + this.world = tileEntity.worldObj; } /** diff --git a/src/minecraft/assemblyline/common/machine/armbot/CommandIdle.java b/src/minecraft/assemblyline/common/machine/armbot/CommandIdle.java index d89673d6..81193fa4 100644 --- a/src/minecraft/assemblyline/common/machine/armbot/CommandIdle.java +++ b/src/minecraft/assemblyline/common/machine/armbot/CommandIdle.java @@ -4,6 +4,9 @@ import assemblyline.common.machine.crafter.TileEntityArmbot; public class CommandIdle extends Command { + public static final float IDLE_ROTATION_PITCH = 0; + public static final float IDLE_ROTATION_YAW = 0; + public CommandIdle(TileEntityArmbot arm) { super(arm); @@ -12,10 +15,20 @@ public class CommandIdle extends Command protected boolean doTask() { /** - * randomly move the arm to similate life in the arm if the arm is powered + * Move the arm rotation to idle position if the machine is not idling */ - return true; + if (this.tileEntity.rotationPitch != IDLE_ROTATION_PITCH && this.tileEntity.rotationYaw != IDLE_ROTATION_YAW) + { + this.tileEntity.rotationPitch += (IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) * 0.05; + this.tileEntity.rotationYaw += (IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) * 0.05; + 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(); + return false; } } diff --git a/src/minecraft/assemblyline/common/machine/crafter/TileEntityArmbot.java b/src/minecraft/assemblyline/common/machine/crafter/TileEntityArmbot.java index e7bac658..e64ceada 100644 --- a/src/minecraft/assemblyline/common/machine/crafter/TileEntityArmbot.java +++ b/src/minecraft/assemblyline/common/machine/crafter/TileEntityArmbot.java @@ -41,6 +41,12 @@ public class TileEntityArmbot extends TileEntityElectricityReceiver implements I private int playerUsing = 0; + /** + * The rotation of the arms. + */ + public float rotationPitch = 0; + public float rotationYaw = 0; + @Override public void initiate() { @@ -80,7 +86,7 @@ public class TileEntityArmbot extends TileEntityElectricityReceiver implements I } } - taskManager.onUpdate(); + this.taskManager.onUpdate(); if (this.ticks % 5 == 0 && !this.isDisabled() && this.taskManager.hasTasks() && EntityArm != null) {