Improved Idle Command

This commit is contained in:
Henry Mao 2013-01-08 19:19:47 +08:00
parent 88f5e31eef
commit f0dcceddb7
7 changed files with 35 additions and 49 deletions

View file

@ -1 +1 @@
44
46

9
obf.rgs Normal file
View file

@ -0,0 +1,9 @@
# Ignore all classes
.class **
# Except a specific class
!class assemblyline/**
.option Annotations
.option Trim

View file

@ -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;
}
}
}

View file

@ -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
{

View file

@ -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;
}
/**

View file

@ -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;
}
}

View file

@ -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)
{