protected override void DoDeviceComplete() { deviceState = enDeviceState.IDLE; BlockPos bp = Pos.Copy().Offset(outputFace); BlockEntity checkblock = Api.World.BlockAccessor.GetBlockEntity(bp); var outputContainer = checkblock as BlockEntityContainer; if (Api.World is IServerWorldAccessor) { DummyInventory dummy = new DummyInventory(Api); List <ItemStack> outputitems = MacerationRecipe.GetMacerate(workingitem, Api, MachineName); foreach (ItemStack outitem in outputitems) { if (outitem == null) { continue; } dummy[0].Itemstack = outitem; //no output conatiner, spitout stuff if (outputContainer != null) { bool stoptrying = false; int safetycounter = 0; while (!stoptrying) { WeightedSlot tryoutput = outputContainer.Inventory.GetBestSuitedSlot(dummy[0]); if (tryoutput.slot != null) { ItemStackMoveOperation op = new ItemStackMoveOperation(Api.World, EnumMouseButton.Left, 0, EnumMergePriority.DirectMerge, dummy[0].StackSize); dummy[0].TryPutInto(tryoutput.slot, ref op); tryoutput.slot.MarkDirty(); if (dummy[0] == null) { stoptrying = true; } else if (dummy[0].StackSize == 0) { stoptrying = true; } } else { stoptrying = true; } safetycounter++; if (safetycounter > 24) { stoptrying = true; } } } Vec3d pos = bp.ToVec3d(); dummy.DropAll(pos); } } }
protected override void DoDeviceComplete() { deviceState = enDeviceState.IDLE; string userecipe = recipe; if (ingredient_subtype != "") { userecipe += "-" + ingredient_subtype; } Block outputBlock = Api.World.GetBlock(new AssetLocation(userecipe)); Item outputItem = Api.World.GetItem(new AssetLocation(userecipe)); if (outputBlock == null && outputItem == null) { deviceState = enDeviceState.ERROR; return; } ItemStack outputStack; if (outputBlock != null) { outputStack = new ItemStack(outputBlock, outputQuantity); } else { outputStack = new ItemStack(outputItem, outputQuantity); } dummy[0].Itemstack = outputStack; outputStack.Collectible.SetTemperature(Api.World, outputStack, lastheatreading); BlockPos bp = Pos.Copy().Offset(outputFace); BlockEntity checkblock = Api.World.BlockAccessor.GetBlockEntity(bp); var outputContainer = checkblock as BlockEntityContainer; if (outputContainer != null) { WeightedSlot tryoutput = outputContainer.Inventory.GetBestSuitedSlot(dummy[0]); if (tryoutput.slot != null) { ItemStackMoveOperation op = new ItemStackMoveOperation(Api.World, EnumMouseButton.Left, 0, EnumMergePriority.DirectMerge, outputQuantity); dummy[0].TryPutInto(tryoutput.slot, ref op); } } if (!dummy.Empty) { //If no storage then spill on the ground Vec3d pos = Pos.ToVec3d(); dummy.DropAll(pos); } Api.World.PlaySoundAt(new AssetLocation("sounds/doorslide"), Pos.X, Pos.Y, Pos.Z, null, false, 8, 1); if (Api.World.Side == EnumAppSide.Client && animUtil != null) { animUtil.StopAnimation(Pos.ToString() + animationName); } }
protected override void DoDeviceComplete() { deviceState = enDeviceState.IDLE; Block outputItem = Api.World.GetBlock(new AssetLocation(recipe)); if (outputItem == null) { deviceState = enDeviceState.ERROR; return; } ItemStack outputStack = new ItemStack(outputItem, outputQuantiy); dummy[0].Itemstack = outputStack; BlockPos bp = Pos.Copy().Offset(outputFace); BlockEntity checkblock = Api.World.BlockAccessor.GetBlockEntity(bp); var outputContainer = checkblock as BlockEntityContainer; if (outputContainer != null) { WeightedSlot tryoutput = outputContainer.Inventory.GetBestSuitedSlot(dummy[0]); if (tryoutput != null) { ItemStackMoveOperation op = new ItemStackMoveOperation(Api.World, EnumMouseButton.Left, 0, EnumMergePriority.DirectMerge, outputQuantiy); int qmoved = dummy[0].TryPutInto(tryoutput.slot, ref op); } } if (!dummy.Empty) { //If no storage then spill on the ground Vec3d pos = Pos.ToVec3d(); dummy.DropAll(pos); } Api.World.PlaySoundAt(new AssetLocation("sounds/doorslide"), Pos.X, Pos.Y, Pos.Z, null, false, 8, 1); if (Api.World.Side == EnumAppSide.Client && animUtil != null) { animUtil.StopAnimation("process"); } }