/// <summary> /// Attempts to move the item from slot to slot. /// </summary> /// <param name="dt"></param> public void MoveItem(float dt) { itemFlowAccum = Math.Min(itemFlowAccum + ItemFlowRate, Math.Max(1, ItemFlowRate * 2)); if (itemFlowAccum < 1) { return; } if (PushFaces != null && PushFaces.Length > 0 && !inventory.Empty) { ItemStack stack = inventory.First(slot => !slot.Empty).Itemstack; BlockFacing outputFace = PushFaces[Api.World.Rand.Next(PushFaces.Length)]; int dir = stack.Attributes.GetInt("chuteDir", -1); BlockFacing desiredDir = dir >= 0 && PushFaces.Contains(BlockFacing.ALLFACES[dir]) ? BlockFacing.ALLFACES[dir] : null; // If we have a desired dir, try to go there if (desiredDir != null) { // Try spit it out first if (!TrySpitOut(desiredDir)) { // Then try push it in there, if (!TryPushInto(desiredDir) && outputFace != desiredDir.Opposite) { // Otherwise try spit it out in a random face, but only if its not back where it came frome if (!TrySpitOut(outputFace)) { TryPushInto(outputFace); } } } } else { // Without a desired dir, try to spit it out anywhere first if (!TrySpitOut(outputFace)) { // Then try push it anywhere next TryPushInto(outputFace); } } } if (PullFaces != null && PullFaces.Length > 0 && inventory.Empty) { BlockFacing inputFace = PullFaces[Api.World.Rand.Next(PullFaces.Length)]; TryPullFrom(inputFace); } }