private void RedistributeStacks(int intoSlotId)
        {
            int stacksPerSlot = referenceDistributStack.StackSize / leftMouseDownDistributeSlotsBySlotid.Count;

            for (int i = 0; i < leftMouseDownDistributeSlotsBySlotid.Count - 1; i++)
            {
                int sourceSlotid = leftMouseDownDistributeSlotsBySlotid.GetKeyAtIndex(i);
                if (sourceSlotid == intoSlotId)
                {
                    continue;
                }

                ItemSlot sourceSlot = inventory[sourceSlotid];

                int beforesize = leftMouseDownDistributeSlotsBySlotid[sourceSlotid];
                int nowsize    = sourceSlot.StackSize;

                if (nowsize - beforesize > stacksPerSlot)
                {
                    ItemSlot targetSlot       = inventory[intoSlotId];
                    ItemStackMoveOperation op = new ItemStackMoveOperation(api.World, EnumMouseButton.Left, 0, EnumMergePriority.AutoMerge);
                    op.ActingPlayer      = api.World.Player;
                    op.RequestedQuantity = nowsize - beforesize - stacksPerSlot;

                    object packet = api.World.Player.InventoryManager.TryTransferTo(sourceSlot, targetSlot, ref op);

                    if (packet != null)
                    {
                        SendPacketHandler(packet);
                    }
                }
            }
        }
示例#2
0
        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);
                }
            }
        }
示例#3
0
        protected override void ActivateSlotLeftClick(ItemSlot sourceSlot, ref ItemStackMoveOperation op)
        {
            IWorldAccessor world       = inventory.Api.World;
            BlockBucket    bucketblock = sourceSlot.Itemstack?.Block as BlockBucket;

            if (bucketblock != null)
            {
                ItemStack bucketContents = bucketblock.GetContent(world, sourceSlot.Itemstack);
                bool      stackable      = !Empty && itemstack.Equals(world, bucketContents, GlobalConstants.IgnoredStackAttributes);

                if ((Empty || stackable) && bucketContents != null)
                {
                    ItemStack bucketStack  = sourceSlot.Itemstack;
                    ItemStack takenContent = bucketblock.TryTakeContent(world, bucketStack, 1);
                    sourceSlot.Itemstack    = bucketStack;
                    takenContent.StackSize += StackSize;
                    this.itemstack          = takenContent;
                    MarkDirty();
                    return;
                }

                return;
            }

            base.ActivateSlotLeftClick(sourceSlot, ref op);
        }
        private void SlotMouseWheel(int slotId, int wheelDelta)
        {
            ItemStackMoveOperation op = new ItemStackMoveOperation(api.World, EnumMouseButton.Wheel, 0, EnumMergePriority.AutoMerge, 1);

            op.WheelDir     = wheelDelta > 0 ? 1 : -1;
            op.ActingPlayer = api.World.Player;
            IInventory mouseCursorInv = api.World.Player.InventoryManager.GetOwnInventory(GlobalConstants.mousecursorInvClassName);

            IInventory targetInv  = inventory;
            ItemSlot   sourceSlot = mouseCursorInv[0];

            var packet = targetInv.ActivateSlot(slotId, sourceSlot, ref op);

            if (packet != null)
            {
                if (packet is object[] packets)
                {
                    for (int i = 0; i < packets.Length; i++)
                    {
                        SendPacketHandler(packets[i]);
                    }
                }
                else
                {
                    SendPacketHandler?.Invoke(packet);
                }
            }
        }
        public override bool TryGiveItemStack(ItemStack itemstack)
        {
            if (itemstack == null || itemstack.StackSize == 0)
            {
                return(false);
            }

            ItemSlot dummySlot = new DummySlot(null);

            dummySlot.Itemstack = itemstack.Clone();

            ItemStackMoveOperation op = new ItemStackMoveOperation(World, EnumMouseButton.Left, 0, EnumMergePriority.AutoMerge, itemstack.StackSize);

            WeightedSlot wslot = inv.GetBestSuitedSlot(dummySlot, new List <ItemSlot>());

            if (wslot.weight > 0)
            {
                dummySlot.TryPutInto(wslot.slot, ref op);
                itemstack.StackSize -= op.MovedQuantity;
                WatchedAttributes.MarkAllDirty();
                return(op.MovedQuantity > 0);
            }

            return(false);
        }
示例#6
0
        bool AddIngot(ItemSlot slot)
        {
            if (IngotCount >= 16)
            {
                capi?.TriggerIngameError(this, "notenoughfuel", Lang.Get("This stone coffin is full already"));
                return(false);
            }

            if (slot.Itemstack.ItemAttributes?["carburizableProps"].Exists == false)
            {
                capi?.TriggerIngameError(this, "wrongfuel", Lang.Get("Next add some carburizable metal ingots"));
                return(false);
            }

            ItemStackMoveOperation op = new ItemStackMoveOperation(Api.World, EnumMouseButton.Left, 0, EnumMergePriority.DirectMerge, 1);
            int moved = slot.TryPutInto(inv[1], ref op);

            if (moved == 0)
            {
                capi?.TriggerIngameError(this, "cannotmixfuels", Lang.Get("Cannot mix ingots, it will mess with the carburisation process!"));
                return(false);
            }

            updateSelectiveElements();
            MarkDirty(true);

            return(true);
        }
示例#7
0
        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);
            }
        }
示例#8
0
        private void TryPullFrom(BlockFacing inputFace)
        {
            BlockPos InputPosition = Pos.AddCopy(inputFace);

            if (Api.World.BlockAccessor.GetBlockEntity(InputPosition) is BlockEntityContainer beContainer)
            {
                //do not both push and pull across the same chute-chute connection
                if (beContainer.Block is BlockChute chute)
                {
                    string[] pushFaces = chute.Attributes["pushFaces"].AsArray <string>(null);
                    if (pushFaces?.Contains(inputFace.Opposite.Code) == true)
                    {
                        return;
                    }
                }

                ItemSlot            sourceSlot = beContainer.Inventory.GetAutoPullFromSlot(inputFace.Opposite);
                ItemSlot            targetSlot = sourceSlot == null ? null : inventory.GetBestSuitedSlot(sourceSlot).slot;
                BlockEntityItemFlow beFlow     = beContainer as BlockEntityItemFlow;

                if (sourceSlot != null && targetSlot != null && (beFlow == null || targetSlot.Empty))
                {
                    ItemStackMoveOperation op = new ItemStackMoveOperation(Api.World, EnumMouseButton.Left, 0, EnumMergePriority.DirectMerge, (int)itemFlowAccum);

                    int horTravelled = sourceSlot.Itemstack.Attributes.GetInt("chuteQHTravelled");
                    if (horTravelled < 2)
                    {
                        int qmoved = sourceSlot.TryPutInto(targetSlot, ref op);
                        if (qmoved > 0)
                        {
                            if (beFlow != null)
                            {
                                targetSlot.Itemstack.Attributes.SetInt("chuteQHTravelled", inputFace.IsHorizontal ? (horTravelled + 1): 0);
                                targetSlot.Itemstack.Attributes.SetInt("chuteDir", inputFace.Opposite.Index);
                            }
                            else
                            {
                                targetSlot.Itemstack.Attributes.RemoveAttribute("chuteQHTravelled");
                                targetSlot.Itemstack.Attributes.RemoveAttribute("chuteDir");
                            }

                            sourceSlot.MarkDirty();
                            targetSlot.MarkDirty();
                            MarkDirty(false);
                            beFlow?.MarkDirty();
                        }

                        if (qmoved > 0 && Api.World.Rand.NextDouble() < 0.2)
                        {
                            Api.World.PlaySoundAt(hopperTumble, Pos.X + 0.5, Pos.Y + 0.5, Pos.Z + 0.5, null, true, 8, 0.5f);

                            itemFlowAccum -= qmoved;
                        }
                    }
                }
            }
        }
示例#9
0
        public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel)
        {
            int       stage = Stage;
            ItemStack stack = byPlayer.InventoryManager.ActiveHotbarSlot?.Itemstack;

            if (stage == 5)
            {
                BlockEntityKiln bef = world.BlockAccessor.GetBlockEntity(blockSel.Position) as BlockEntityKiln;

                if (bef != null && stack?.Block != null && stack.Block.HasBehavior <BlockBehaviorCanIgnite>())
                {
                    return(false);
                }

                if (bef != null && stack != null && byPlayer.Entity.Controls.Sneak)
                {
                    if (stack.Collectible.CombustibleProps != null && stack.Collectible.CombustibleProps.MeltingPoint > 0)
                    {
                        ItemStackMoveOperation op = new ItemStackMoveOperation(world, EnumMouseButton.Button1, 0, EnumMergePriority.DirectMerge, 1);
                        byPlayer.InventoryManager.ActiveHotbarSlot.TryPutInto(bef.inputSlot, ref op);
                        if (op.MovedQuantity > 0)
                        {
                            (byPlayer as IClientPlayer)?.TriggerFpAnimation(EnumHandInteract.HeldItemInteract);
                            return(true);
                        }
                    }

                    if (stack.Collectible.CombustibleProps != null && stack.Collectible.CombustibleProps.BurnTemperature > 0)
                    {
                        ItemStackMoveOperation op = new ItemStackMoveOperation(world, EnumMouseButton.Button1, 0, EnumMergePriority.DirectMerge, 1);
                        byPlayer.InventoryManager.ActiveHotbarSlot.TryPutInto(bef.fuelSlot, ref op);
                        if (op.MovedQuantity > 0)
                        {
                            (byPlayer as IClientPlayer)?.TriggerFpAnimation(EnumHandInteract.HeldItemInteract);
                            return(true);
                        }
                    }
                }

                return(base.OnBlockInteractStart(world, byPlayer, blockSel));
            }


            if (stack != null && TryConstruct(world, blockSel.Position, stack.Collectible, byPlayer))
            {
                if (byPlayer != null && byPlayer.WorldData.CurrentGameMode != EnumGameMode.Creative)
                {
                    byPlayer.InventoryManager.ActiveHotbarSlot.TakeOut(1);
                }
                return(true);
            }


            return(false);
        }
示例#10
0
        public override void ActivateSlot(ItemSlot sourceSlot, ref ItemStackMoveOperation op)
        {
            if (Empty && sourceSlot.Empty)
            {
                return;
            }

            switch (op.MouseButton)
            {
            case EnumMouseButton.Right:
                ActivateSlotRightClick(sourceSlot, ref op);
                return;
            }
        }
        private void RedistributeStacks(int intoSlotId)
        {
            int stacksPerSlot = referenceDistributStack.StackSize / distributeStacksPrevStackSizeBySlotId.Count;

            for (int i = 0; i < distributeStacksPrevStackSizeBySlotId.Count - 1; i++)
            {
                int sourceSlotid = distributeStacksPrevStackSizeBySlotId.GetKeyAtIndex(i);
                if (sourceSlotid == intoSlotId)
                {
                    continue;
                }

                ItemSlot sourceSlot = inventory[sourceSlotid];

                distributeStacksAddedStackSizeBySlotId.TryGetValue(sourceSlotid, out int addedSrcSize);

                if (addedSrcSize > stacksPerSlot)
                {
                    int beforeSrcSize = distributeStacksPrevStackSizeBySlotId[sourceSlotid];
                    int nowSrcSize    = beforeSrcSize + addedSrcSize;

                    ItemSlot targetSlot       = inventory[intoSlotId];
                    ItemStackMoveOperation op = new ItemStackMoveOperation(api.World, EnumMouseButton.Left, 0, EnumMergePriority.AutoMerge);
                    op.ActingPlayer      = api.World.Player;
                    op.RequestedQuantity = nowSrcSize - beforeSrcSize - stacksPerSlot;

                    int moved = nowSrcSize - beforeSrcSize - stacksPerSlot;

                    object packet = api.World.Player.InventoryManager.TryTransferTo(sourceSlot, targetSlot, ref op);


                    distributeStacksAddedStackSizeBySlotId.TryGetValue(intoSlotId, out int addedBefore);
                    distributeStacksAddedStackSizeBySlotId[intoSlotId] = addedBefore + op.MovedQuantity;

                    distributeStacksAddedStackSizeBySlotId[sourceSlotid] -= op.MovedQuantity;

                    //Console.WriteLine(distributeStacksPrevStackSizeBySlotId.Count + " client side redist stack. Move {0}-{4}-{5} from {1} to {2}, slot has now {3}x", nowSrcSize, sourceSlotid, intoSlotId, distributeStacksAddedStackSizeBySlotId[intoSlotId] + distributeStacksPrevStackSizeBySlotId[intoSlotId], beforeSrcSize, stacksPerSlot);



                    if (packet != null)
                    {
                        SendPacketHandler(packet);
                    }
                }
            }
        }
        public virtual void SlotClick(ICoreClientAPI api, int slotId, EnumMouseButton mouseButton, bool shiftPressed, bool ctrlPressed, bool altPressed)
        {
            //Console.WriteLine("client side slot click on " + slotId);

            List <IInventory> inventories    = api.World.Player.InventoryManager.OpenedInventories;
            IInventory        mouseCursorInv = api.World.Player.InventoryManager.GetOwnInventory(GlobalConstants.mousecursorInvClassName);
            object            packet;

            EnumModifierKey modifiers =
                (shiftPressed ? EnumModifierKey.SHIFT : 0) |
                (ctrlPressed ? EnumModifierKey.CTRL : 0) |
                (altPressed ? EnumModifierKey.ALT : 0)
            ;

            ItemStackMoveOperation op = new ItemStackMoveOperation(api.World, mouseButton, modifiers, EnumMergePriority.AutoMerge);

            op.ActingPlayer = api.World.Player;

            if (shiftPressed)
            {
                ItemSlot sourceSlot = inventory[slotId];
                op.RequestedQuantity = sourceSlot.StackSize;
                packet = inventory.ActivateSlot(slotId, sourceSlot, ref op);
            }
            else
            {
                op.CurrentPriority = EnumMergePriority.DirectMerge;
                packet             = inventory.ActivateSlot(slotId, mouseCursorInv[0], ref op);
            }

            if (packet != null)
            {
                if (packet is object[] packets)
                {
                    for (int i = 0; i < packets.Length; i++)
                    {
                        SendPacketHandler(packets[i]);
                    }
                }
                else
                {
                    SendPacketHandler?.Invoke(packet);
                }
            }

            api.Input.TriggerOnMouseClickSlot(inventory[slotId]);
        }
示例#13
0
        public override object ActivateSlot(int slotId, ItemSlot mouseSlot, ref ItemStackMoveOperation op)
        {
            // Player clicked an item from the selling list, move to buying cart
            if (slotId <= 15)
            {
                AddToBuyingCart(slots[slotId] as ItemSlotTrade);
                return(InvNetworkUtil.GetActivateSlotPacket(slotId, op));
            }

            // Player clicked an item in the buying cart, remove it
            if (slotId <= 19)
            {
                ItemSlotTrade cartSlot = slots[slotId] as ItemSlotTrade;

                if (op.MouseButton == EnumMouseButton.Right)
                {
                    // Just remove one batch on right mouse
                    if (cartSlot.TradeItem?.Stack != null)
                    {
                        cartSlot.TakeOut(cartSlot.TradeItem.Stack.StackSize);
                        cartSlot.MarkDirty();
                    }
                }
                else
                {
                    cartSlot.Itemstack = null;
                    cartSlot.MarkDirty();
                }

                return(InvNetworkUtil.GetActivateSlotPacket(slotId, op));
            }

            // Player clicked an item on the buy slot, ignore it
            if (slotId <= 34)
            {
                return(InvNetworkUtil.GetActivateSlotPacket(slotId, op));
            }

            // Player clicked an item in the selling cart, act like a normal slot
            if (slotId <= 39)
            {
                return(base.ActivateSlot(slotId, mouseSlot, ref op));
            }

            return(InvNetworkUtil.GetActivateSlotPacket(slotId, op));
        }
示例#14
0
        public static void Sort(this IInventory activeInv, ICoreAPI api, EnumSortMode mode)
        {
            if (api == null || activeInv == null)
            {
                return;
            }
            string name = activeInv.ClassName;

            if (name == "basket" || name == "chest" || name == "hotbar" || name == "backpack")
            {
                List <ItemStack> objects = activeInv.SortArr(mode);

                for (int j = 0; j < activeInv.Count; j++)
                {
                    if (activeInv[j] is ItemSlotOffhand)
                    {
                        continue;
                    }

                    if (activeInv[j].Itemstack != null)
                    {
                        if (activeInv[j].Itemstack.Attributes["backpack"] != null)
                        {
                            continue;
                        }

                        activeInv[j].TakeOutWhole();
                    }
                    for (int o = objects.Count; o-- > 0;)
                    {
                        ItemStackMoveOperation op = new ItemStackMoveOperation(api.World, EnumMouseButton.Left, 0, EnumMergePriority.AutoMerge, 1);
                        DummySlot slot            = new DummySlot(objects[o]);

                        slot.TryPutInto(activeInv[j], ref op);
                        if (op.MovedQuantity > 0)
                        {
                            objects.RemoveAt(o);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }
示例#15
0
            public void OnTick(float par)
            {
                //Check for fireplace (use first found)
                BlockPos checkPos = new BlockPos(Pos.X, Pos.Y - 1, Pos.Z);


                var firepit = Api.World.BlockAccessor.GetBlockEntity(checkPos) as BlockEntityFirepit;

                //NO Firepit then you musta quit
                if (firepit == null)
                {
                    return;
                }
                if (firepit.inputSlot == null)
                {
                    return;
                }
                if (firepit.inputSlot.StackSize > 0)
                {
                    return;
                }
                //Find Input chest
                checkPos = new BlockPos(Pos.X, Pos.Y + 1, Pos.Z);
                var inputContainer = Api.World.BlockAccessor.GetBlockEntity(checkPos) as BlockEntityContainer;

                if (inputContainer == null)
                {
                    return;
                }
                ItemSlot sourceSlot = inputContainer.Inventory.GetAutoPullFromSlot(BlockFacing.DOWN);

                if (sourceSlot == null)
                {
                    return;
                }
                int quantity = 1;
                ItemStackMoveOperation op = new ItemStackMoveOperation(Api.World, EnumMouseButton.Left, 0, EnumMergePriority.DirectMerge, quantity);

                int qmoved = sourceSlot.TryPutInto(firepit.inputSlot, ref op);

                firepit.outputSlot.MarkDirty();
                sourceSlot.MarkDirty();
            }
示例#16
0
            public void OnTick(float par)
            {
                //find a firepit above us
                BlockPos checkPos = new BlockPos(Pos.X, Pos.Y + 1, Pos.Z);

                checkblock = Api.World.BlockAccessor.GetBlockEntity(checkPos);
                //Nothing at firepit location, nothing we can do, there is no point, good day sir!

                var firepit = checkblock as BlockEntityFirepit;

                //NO Firepit then you musta quit
                if (firepit == null)
                {
                    return;
                }
                if (firepit.outputStack == null)
                {
                    return;
                }
                if (firepit.outputStack.StackSize == 0)
                {
                    return;
                }
                checkPos = new BlockPos(Pos.X, Pos.Y - 1, Pos.Z);
                var outputContainer = Api.World.BlockAccessor.GetBlockEntity(checkPos) as BlockEntityContainer;

                if (outputContainer == null)
                {
                    return;
                }

                ItemSlot targetSlot = outputContainer.Inventory.GetAutoPushIntoSlot(BlockFacing.UP, firepit.outputSlot);

                if (targetSlot != null)
                {
                    int quantity = 1;
                    ItemStackMoveOperation op = new ItemStackMoveOperation(Api.World, EnumMouseButton.Left, 0, EnumMergePriority.DirectMerge, quantity);

                    int qmoved = firepit.outputSlot.TryPutInto(targetSlot, ref op);
                    firepit.outputSlot.MarkDirty();
                    targetSlot.MarkDirty();
                }
            }
示例#17
0
        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");
            }
        }
示例#18
0
        public override void ActivateSlot(ItemSlot sourceSlot, ref ItemStackMoveOperation op)
        {
            if (Empty)
            {
                return;
            }
            if (sourceSlot.CanHold(this))
            {
                if (sourceSlot.Itemstack != null && sourceSlot.Itemstack != null && sourceSlot.Itemstack.Collectible.GetMergableQuantity(sourceSlot.Itemstack, itemstack, op.CurrentPriority) < itemstack.StackSize)
                {
                    return;
                }

                op.RequestedQuantity = StackSize;

                TryPutInto(sourceSlot, ref op);

                if (op.MovedQuantity > 0)
                {
                    OnItemSlotModified(itemstack);
                }
            }
        }
示例#19
0
        protected override void ActivateSlotRightClick(ItemSlot sourceSlot, ref ItemStackMoveOperation op)
        {
            IWorldAccessor world       = inventory.Api.World;
            BlockBucket    bucketblock = sourceSlot.Itemstack?.Block as BlockBucket;

            if (bucketblock != null)
            {
                if (Empty)
                {
                    return;
                }

                ItemStack bucketContents = bucketblock.GetContent(world, sourceSlot.Itemstack);

                if (bucketContents == null)
                {
                    TakeOut(bucketblock.TryAddContent(world, sourceSlot.Itemstack, Itemstack, 1));
                    MarkDirty();
                }
                else
                {
                    if (itemstack.Equals(world, bucketContents, GlobalConstants.IgnoredStackAttributes))
                    {
                        TakeOut(bucketblock.TryAddContent(world, sourceSlot.Itemstack, bucketblock.GetContent(world, sourceSlot.Itemstack), 1));
                        MarkDirty();
                        return;
                    }
                }


                return;
            }


            base.ActivateSlotRightClick(sourceSlot, ref op);
        }
示例#20
0
        public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel)
        {
            int       stage = Stage;
            ItemStack stack = byPlayer.InventoryManager.ActiveHotbarSlot?.Itemstack;

            if (stage == 5)
            {
                BlockEntityFirepit bef = world.BlockAccessor.GetBlockEntity(blockSel.Position) as BlockEntityFirepit;

                if (bef != null && stack != null && byPlayer.Entity.Controls.Sneak)
                {
                    if (stack.Collectible.CombustibleProps != null && stack.Collectible.CombustibleProps.MeltingPoint > 0)
                    {
                        ItemStackMoveOperation op = new ItemStackMoveOperation(world, EnumMouseButton.Button1, 0, EnumMergePriority.DirectMerge, 1);
                        byPlayer.InventoryManager.ActiveHotbarSlot.TryPutInto(bef.inputSlot, ref op);
                        if (op.MovedQuantity > 0)
                        {
                            return(true);
                        }
                    }

                    if (stack.Collectible.CombustibleProps != null && stack.Collectible.CombustibleProps.BurnTemperature > 0)
                    {
                        ItemStackMoveOperation op = new ItemStackMoveOperation(world, EnumMouseButton.Button1, 0, EnumMergePriority.DirectMerge, 1);
                        byPlayer.InventoryManager.ActiveHotbarSlot.TryPutInto(bef.fuelSlot, ref op);
                        if (op.MovedQuantity > 0)
                        {
                            return(true);
                        }
                    }
                }

                if (stack?.Collectible is BlockBowl && (stack.Collectible as BlockBowl)?.BowlContentItemCode() == null && stack.Collectible.Attributes?["mealContainer"].AsBool() == true)
                {
                    ItemSlot potSlot = null;
                    if (bef?.inputStack?.Collectible is CookedContainerFix)
                    {
                        potSlot = bef.inputSlot;
                    }
                    if (bef?.outputStack?.Collectible is CookedContainerFix)
                    {
                        potSlot = bef.outputSlot;
                    }

                    if (potSlot != null)
                    {
                        CookedContainerFix blockPot   = potSlot.Itemstack.Collectible as CookedContainerFix;
                        ItemSlot           targetSlot = byPlayer.InventoryManager.ActiveHotbarSlot;
                        if (byPlayer.InventoryManager.ActiveHotbarSlot.StackSize > 1)
                        {
                            targetSlot = new DummySlot(targetSlot.TakeOut(1));
                            byPlayer.InventoryManager.ActiveHotbarSlot.MarkDirty();
                            blockPot.ServeIntoBowlStack(targetSlot, potSlot, world);
                            if (!byPlayer.InventoryManager.TryGiveItemstack(targetSlot.Itemstack, true))
                            {
                                world.SpawnItemEntity(targetSlot.Itemstack, byPlayer.Entity.ServerPos.XYZ);
                            }
                        }
                        else
                        {
                            blockPot.ServeIntoBowlStack(targetSlot, potSlot, world);
                        }
                    }

                    return(true);
                }
                return(base.OnBlockInteractStart(world, byPlayer, blockSel));
            }


            if (stack != null && TryConstruct(world, blockSel.Position, stack.Collectible, byPlayer))
            {
                if (byPlayer != null && byPlayer.WorldData.CurrentGameMode != EnumGameMode.Creative)
                {
                    byPlayer.InventoryManager.ActiveHotbarSlot.TakeOut(1);
                }
                return(true);
            }


            return(false);
        }
示例#21
0
        private bool TryPushInto(BlockFacing outputFace)
        {
            BlockPos OutputPosition = Pos.AddCopy(outputFace);

            if (Api.World.BlockAccessor.GetBlockEntity(OutputPosition) is BlockEntityContainer beContainer)
            {
                ItemSlot sourceSlot = inventory.FirstOrDefault(slot => !slot.Empty);
                if ((sourceSlot?.Itemstack?.StackSize ?? 0) == 0)
                {
                    return(false);                                               //seems FirstOrDefault() method can sometimes give a slot with stacksize == 0, weird
                }
                int horTravelled = sourceSlot.Itemstack.Attributes.GetInt("chuteQHTravelled");
                int chuteDir     = sourceSlot.Itemstack.Attributes.GetInt("chuteDir");
                sourceSlot.Itemstack.Attributes.RemoveAttribute("chuteQHTravelled");
                sourceSlot.Itemstack.Attributes.RemoveAttribute("chuteDir");

                if (horTravelled >= 2)
                {
                    return(false);                    //chutes can't move items more than 1 block horizontally without a drop
                }
                ItemSlot            targetSlot = beContainer.Inventory.GetAutoPushIntoSlot(outputFace.Opposite, sourceSlot);
                BlockEntityItemFlow beFlow     = beContainer as BlockEntityItemFlow;

                if (targetSlot != null && (beFlow == null || targetSlot.Empty))
                {
                    int quantity = (int)itemFlowAccum;
                    ItemStackMoveOperation op = new ItemStackMoveOperation(Api.World, EnumMouseButton.Left, 0, EnumMergePriority.DirectMerge, quantity);

                    int qmoved = sourceSlot.TryPutInto(targetSlot, ref op);

                    if (qmoved > 0)
                    {
                        if (Api.World.Rand.NextDouble() < 0.2)
                        {
                            Api.World.PlaySoundAt(hopperTumble, Pos.X + 0.5, Pos.Y + 0.5, Pos.Z + 0.5, null, true, 8, 0.5f);
                        }

                        if (beFlow != null)
                        {
                            targetSlot.Itemstack.Attributes.SetInt("chuteQHTravelled", outputFace.IsHorizontal ? (horTravelled + 1) : 0);
                            targetSlot.Itemstack.Attributes.SetInt("chuteDir", outputFace.Index);
                        }
                        else
                        {
                            targetSlot.Itemstack.Attributes.RemoveAttribute("chuteQHTravelled");
                            targetSlot.Itemstack.Attributes.RemoveAttribute("chuteDir");
                        }

                        sourceSlot.MarkDirty();
                        targetSlot.MarkDirty();
                        MarkDirty(false);
                        beFlow?.MarkDirty(false);

                        itemFlowAccum -= qmoved;

                        return(true);
                    }
                    else
                    {
                        //If the push failed, re-apply original chuteDir so that the itemStack still has it for next push attempt
                        sourceSlot.Itemstack.Attributes.SetInt("chuteDir", chuteDir);
                    }
                }
            }

            return(false);
        }
        protected override void ActivateSlotRightClick(ItemSlot sourceSlot, ref ItemStackMoveOperation op)
        {
            IWorldAccessor           world       = inventory.Api.World;
            BlockLiquidContainerBase liqCntBlock = sourceSlot.Itemstack?.Block as BlockLiquidContainerBase;

            if (liqCntBlock != null)
            {
                if (Empty)
                {
                    return;
                }

                ItemStack contentStack = liqCntBlock.GetContent(sourceSlot.Itemstack);

                float toMoveLitres    = op.ShiftDown ? liqCntBlock.CapacityLitres : liqCntBlock.TransferSizeLitres;
                var   srcProps        = BlockLiquidContainerBase.GetContainableProps(Itemstack);
                float availableLitres = StackSize / (srcProps?.ItemsPerLitre ?? 1);

                toMoveLitres  = Math.Min(toMoveLitres, availableLitres);
                toMoveLitres *= sourceSlot.Itemstack.StackSize;

                if (contentStack == null)
                {
                    int moved = liqCntBlock.TryPutLiquid(sourceSlot.Itemstack, Itemstack, toMoveLitres / sourceSlot.Itemstack.StackSize);
                    TakeOut(moved * sourceSlot.Itemstack.StackSize);
                    MarkDirty();
                }
                else
                {
                    if (itemstack.Equals(world, contentStack, GlobalConstants.IgnoredStackAttributes))
                    {
                        int moved = liqCntBlock.TryPutLiquid(sourceSlot.Itemstack, liqCntBlock.GetContent(sourceSlot.Itemstack), toMoveLitres / sourceSlot.Itemstack.StackSize);
                        TakeOut(moved * sourceSlot.Itemstack.StackSize);
                        MarkDirty();
                        return;
                    }
                }

                return;
            }


            if (itemstack != null && sourceSlot.Itemstack?.ItemAttributes?["contentItem2BlockCodes"].Exists == true)
            {
                string outBlockCode = sourceSlot.Itemstack.ItemAttributes["contentItem2BlockCodes"][itemstack.Collectible.Code.ToShortString()].AsString();

                if (outBlockCode != null)
                {
                    ItemStack outBlockStack = new ItemStack(world.GetBlock(AssetLocation.Create(outBlockCode, sourceSlot.Itemstack.Collectible.Code.Domain)));

                    if (sourceSlot.StackSize == 1)
                    {
                        sourceSlot.Itemstack = outBlockStack;
                    }
                    else
                    {
                        sourceSlot.Itemstack.StackSize--;
                        if (!op.ActingPlayer.InventoryManager.TryGiveItemstack(outBlockStack))
                        {
                            world.SpawnItemEntity(outBlockStack, op.ActingPlayer.Entity.Pos.XYZ);
                        }
                    }

                    sourceSlot.MarkDirty();
                    TakeOut(1);
                }

                return;
            }

            if (sourceSlot.Itemstack?.ItemAttributes?["contentItem2BlockCodes"].Exists == true || sourceSlot.Itemstack?.ItemAttributes?["contentItemCode"].AsString() != null)
            {
                return;
            }

            base.ActivateSlotRightClick(sourceSlot, ref op);
        }
示例#23
0
        /// <summary>
        /// Attempts to move the item from slot to slot.
        /// </summary>
        /// <param name="dt"></param>
        public void MoveItem(float dt)
        {
            //check above.  Then check below.
            BlockPos InputPosition  = pos.AddCopy(InputFace);
            BlockPos OutputPosition = pos.AddCopy(OutputFace);

            //if inventory below, attempt to move item in me to below
            if (api.World.BlockAccessor.GetBlockEntity(OutputPosition) is BlockEntityContainer && !inventory.IsEmpty)
            {
                BlockEntityContainer outputBox    = (BlockEntityContainer)api.World.BlockAccessor.GetBlockEntity(OutputPosition);
                ItemSlot             transferSlot = null;
                foreach (ItemSlot slot in inventory)
                {
                    if (!slot.Empty)
                    {
                        transferSlot = slot;
                        break;
                    }
                }

                if (transferSlot != null)
                {
                    WeightedSlot ws = outputBox.Inventory.GetBestSuitedSlot(transferSlot);
                    if (ws.slot != null)
                    {
                        ItemStackMoveOperation op = new ItemStackMoveOperation(api.World, EnumMouseButton.Left, 0, EnumMergePriority.DirectMerge, FlowAmount);
                        if (transferSlot.TryPutInto(ws.slot, ref op) > 0)
                        {
                            if (api.World.Rand.NextDouble() < 0.2)
                            {
                                api.World.PlaySoundAt(new AssetLocation("sounds/block/hoppertumble"), pos.X + 0.5, pos.Y + 0.5, pos.Z + 0.5, null, true, 8, 0.5f);
                            }
                        }
                    }
                } //transfer slot
            }     //Output move.

            //if inventory above, attempt to move item from above into me.  (LATER ON: CHECK FILTER)
            if (api.World.BlockAccessor.GetBlockEntity(InputPosition) is BlockEntityContainer)
            {
                BlockEntityContainer inputBox = (BlockEntityContainer)api.World.BlockAccessor.GetBlockEntity(InputPosition);
                if (inputBox.Inventory is InventoryGeneric)
                {
                    InventoryGeneric inputInventory = (InventoryGeneric)inputBox.Inventory;
                    if (!inputInventory.IsEmpty)
                    {
                        ItemSlot transferSlot = null;
                        foreach (ItemSlot slot in inputInventory)
                        {
                            if (!slot.Empty)
                            {
                                transferSlot = slot;
                            }
                        }

                        if (transferSlot != null)
                        {
                            WeightedSlot ws = inventory.GetBestSuitedSlot(transferSlot);
                            if (ws.slot != null)
                            {
                                ItemStackMoveOperation op = new ItemStackMoveOperation(api.World, EnumMouseButton.Left, 0, EnumMergePriority.DirectMerge, FlowAmount);

                                if (transferSlot.TryPutInto(ws.slot, ref op) > 0)
                                {
                                    if (api.World.Rand.NextDouble() < 0.2)
                                    {
                                        api.World.PlaySoundAt(new AssetLocation("sounds/block/hoppertumble"), pos.X + 0.5, pos.Y + 0.5, pos.Z + 0.5, null, true, 8, 0.5f);
                                    }
                                }
                            }
                        } //transfer slot
                    }     //Inventory empty check
                }         //Inventory Generic check.
            }             //Check for Block entity container.
        }
        protected override void ActivateSlotLeftClick(ItemSlot sourceSlot, ref ItemStackMoveOperation op)
        {
            IWorldAccessor           world       = inventory.Api.World;
            BlockLiquidContainerBase liqCntBlock = sourceSlot.Itemstack?.Block as BlockLiquidContainerBase;

            if (liqCntBlock != null)
            {
                ItemStack contentStack = liqCntBlock.GetContent(sourceSlot.Itemstack);
                var       liqProps     = BlockLiquidContainerBase.GetContainableProps(contentStack);

                bool stackable = !Empty && itemstack.Equals(world, contentStack, GlobalConstants.IgnoredStackAttributes);

                if ((Empty || stackable) && contentStack != null)
                {
                    ItemStack bucketStack = sourceSlot.Itemstack;

                    float toMoveLitres  = (op?.ActingPlayer?.Entity.Controls.Sneak ?? false) ? liqCntBlock.CapacityLitres : liqCntBlock.TransferSizeLitres;
                    float curDestLitres = StackSize / liqProps.ItemsPerLitre;
                    float curSrcLitres  = contentStack.StackSize / liqProps.ItemsPerLitre;

                    toMoveLitres = Math.Min(toMoveLitres, curSrcLitres);

                    toMoveLitres *= bucketStack.StackSize;
                    toMoveLitres  = Math.Min(toMoveLitres, capacityLitres - curDestLitres);

                    if (toMoveLitres > 0)
                    {
                        int       moveQuantity      = (int)(liqProps.ItemsPerLitre * toMoveLitres);
                        ItemStack takenContentStack = liqCntBlock.TryTakeContent(bucketStack, moveQuantity / bucketStack.StackSize);

                        takenContentStack.StackSize *= bucketStack.StackSize;
                        takenContentStack.StackSize += StackSize;
                        this.itemstack = takenContentStack;
                        MarkDirty();
                        op.MovedQuantity = moveQuantity;
                    }
                }

                return;
            }

            string contentItemCode = sourceSlot.Itemstack?.ItemAttributes?["contentItemCode"].AsString();

            if (contentItemCode != null)
            {
                ItemStack contentStack = new ItemStack(world.GetItem(AssetLocation.Create(contentItemCode, sourceSlot.Itemstack.Collectible.Code.Domain)));
                bool      stackable    = !Empty && itemstack.Equals(world, contentStack, GlobalConstants.IgnoredStackAttributes);

                if ((Empty || stackable) && contentStack != null)
                {
                    if (stackable)
                    {
                        this.itemstack.StackSize++;
                    }
                    else
                    {
                        this.itemstack = contentStack;
                    }

                    MarkDirty();
                    ItemStack bowlStack = new ItemStack(world.GetBlock(AssetLocation.Create(sourceSlot.Itemstack.ItemAttributes["emptiedBlockCode"].AsString(), sourceSlot.Itemstack.Collectible.Code.Domain)));
                    if (sourceSlot.StackSize == 1)
                    {
                        sourceSlot.Itemstack = bowlStack;
                    }
                    else
                    {
                        sourceSlot.Itemstack.StackSize--;
                        if (!op.ActingPlayer.InventoryManager.TryGiveItemstack(bowlStack))
                        {
                            world.SpawnItemEntity(bowlStack, op.ActingPlayer.Entity.Pos.XYZ);
                        }
                    }
                    sourceSlot.MarkDirty();
                }

                return;
            }

            if (sourceSlot.Itemstack?.ItemAttributes?["contentItem2BlockCodes"].Exists == true)
            {
                return;
            }

            base.ActivateSlotLeftClick(sourceSlot, ref op);
        }
示例#25
0
 public override void ActivateSlot(ItemSlot sourceSlot, ref ItemStackMoveOperation op)
 {
 }
示例#26
0
 public override int TryPutInto(ItemSlot sinkSlot, ref ItemStackMoveOperation op)
 {
     return(0);
 }
示例#27
0
 protected override void ActivateSlotRightClick(ItemSlot sourceSlot, ref ItemStackMoveOperation op)
 {
 }
示例#28
0
        protected override void ActivateSlotRightClick(ItemSlot sourceSlot, ref ItemStackMoveOperation op)
        {
            IWorldAccessor world       = inventory.Api.World;
            BlockBucket    bucketblock = sourceSlot.Itemstack?.Block as BlockBucket;

            if (bucketblock != null)
            {
                if (Empty)
                {
                    return;
                }

                ItemStack bucketContents = bucketblock.GetContent(world, sourceSlot.Itemstack);

                if (bucketContents == null)
                {
                    TakeOut(bucketblock.TryPutContent(world, sourceSlot.Itemstack, Itemstack, 1));
                    MarkDirty();
                }
                else
                {
                    if (itemstack.Equals(world, bucketContents, GlobalConstants.IgnoredStackAttributes))
                    {
                        TakeOut(bucketblock.TryPutContent(world, sourceSlot.Itemstack, bucketblock.GetContent(world, sourceSlot.Itemstack), 1));
                        MarkDirty();
                        return;
                    }
                }

                return;
            }


            if (itemstack != null && sourceSlot.Itemstack?.ItemAttributes?["contentItem2BlockCodes"].Exists == true)
            {
                string outBlockCode = sourceSlot.Itemstack.ItemAttributes["contentItem2BlockCodes"][itemstack.Collectible.Code.ToShortString()].AsString();

                if (outBlockCode != null)
                {
                    ItemStack outBlockStack = new ItemStack(world.GetBlock(AssetLocation.Create(outBlockCode, sourceSlot.Itemstack.Collectible.Code.Domain)));

                    if (sourceSlot.StackSize == 1)
                    {
                        sourceSlot.Itemstack = outBlockStack;
                    }
                    else
                    {
                        sourceSlot.Itemstack.StackSize--;
                        if (!op.ActingPlayer.InventoryManager.TryGiveItemstack(outBlockStack))
                        {
                            world.SpawnItemEntity(outBlockStack, op.ActingPlayer.Entity.Pos.XYZ);
                        }
                    }

                    sourceSlot.MarkDirty();
                    TakeOut(1);
                }

                return;
            }

            if (sourceSlot.Itemstack?.ItemAttributes?["contentItem2BlockCodes"].Exists == true || sourceSlot.Itemstack?.ItemAttributes?["contentItemCode"].AsString() != null)
            {
                return;
            }

            base.ActivateSlotRightClick(sourceSlot, ref op);
        }
示例#29
0
            public void OnTick(float par)
            {
                //Check for container
                BlockPos contPos = new BlockPos(Pos.X, Pos.Y + 1, Pos.Z);

                checkblock = Api.World.BlockAccessor.GetBlockEntity(contPos);
                //if (checkblock == null) { return; } //no container no point running

                var inputContainer = checkblock as BlockEntityContainer;

                if (inputContainer == null)
                {
                    return;
                }

                BlockPos[] checksides =
                {
                    new BlockPos(Pos.X - 1, Pos.Y, Pos.Z),
                    new BlockPos(Pos.X + 1, Pos.Y, Pos.Z),
                    new BlockPos(Pos.X,     Pos.Y, Pos.Z + 1),
                    new BlockPos(Pos.X,     Pos.Y, Pos.Z - 1)
                };

                foreach (BlockPos checkPos in checksides)
                {
                    //try to find a firepit
                    checkblock = Api.World.BlockAccessor.GetBlockEntity(checkPos);
                    //Nothing at firepit location, nothing we can do, there is no point, good day sir!

                    var firepit = checkblock as BlockEntityFirepit;
                    //NO Firepit then you musta quit
                    if (firepit == null)
                    {
                        continue;
                    }

                    if (firepit.inputSlot == null)
                    {
                        continue;
                    }
                    //Don't bother trying to add fuel if nothing is being cooked
                    if (firepit.inputSlot.StackSize == 0)
                    {
                        continue;
                    }
                    if (firepit.fuelSlot == null)
                    {
                        continue;
                    }
                    //IF fuel is in the fuelSlot don't bother
                    if (firepit.fuelSlot.StackSize > 0)
                    {
                        continue;
                    }
                    //TODO figure out how to keep firepit lit, also figure out how to verify fuel
                    //OK looks like we need fuel, attempt to add a piece
                    ItemSlot sourceSlot = inputContainer.Inventory.GetAutoPullFromSlot(BlockFacing.DOWN);
                    if (sourceSlot == null)
                    {
                        continue;
                    }
                    int quantity = 1;
                    ItemStackMoveOperation op = new ItemStackMoveOperation(Api.World, EnumMouseButton.Left, 0, EnumMergePriority.DirectMerge, quantity);

                    int qmoved = sourceSlot.TryPutInto(firepit.fuelSlot, ref op);
                    firepit.fuelSlot.MarkDirty();
                    sourceSlot.MarkDirty();
                }
            }
示例#30
0
        protected override void ActivateSlotLeftClick(ItemSlot sourceSlot, ref ItemStackMoveOperation op)
        {
            IWorldAccessor world       = inventory.Api.World;
            BlockBucket    bucketblock = sourceSlot.Itemstack?.Block as BlockBucket;

            if (bucketblock != null)
            {
                ItemStack bucketContents = bucketblock.GetContent(world, sourceSlot.Itemstack);
                bool      stackable      = !Empty && itemstack.Equals(world, bucketContents, GlobalConstants.IgnoredStackAttributes);

                if ((Empty || stackable) && bucketContents != null)
                {
                    ItemStack bucketStack  = sourceSlot.Itemstack;
                    ItemStack takenContent = bucketblock.TryTakeContent(world, bucketStack, op.ActingPlayer?.Entity?.Controls.Sneak == true ? 10 : 1);
                    sourceSlot.Itemstack    = bucketStack;
                    takenContent.StackSize += StackSize;
                    this.itemstack          = takenContent;
                    MarkDirty();
                    return;
                }

                return;
            }

            string contentItemCode = sourceSlot.Itemstack?.ItemAttributes?["contentItemCode"].AsString();

            if (contentItemCode != null)
            {
                ItemStack contentStack = new ItemStack(world.GetItem(AssetLocation.Create(contentItemCode, sourceSlot.Itemstack.Collectible.Code.Domain)));
                bool      stackable    = !Empty && itemstack.Equals(world, contentStack, GlobalConstants.IgnoredStackAttributes);

                if ((Empty || stackable) && contentStack != null)
                {
                    if (stackable)
                    {
                        this.itemstack.StackSize++;
                    }
                    else
                    {
                        this.itemstack = contentStack;
                    }

                    MarkDirty();
                    ItemStack bowlStack = new ItemStack(world.GetBlock(AssetLocation.Create(sourceSlot.Itemstack.ItemAttributes["emptiedBlockCode"].AsString(), sourceSlot.Itemstack.Collectible.Code.Domain)));
                    if (sourceSlot.StackSize == 1)
                    {
                        sourceSlot.Itemstack = bowlStack;
                    }
                    else
                    {
                        sourceSlot.Itemstack.StackSize--;
                        if (!op.ActingPlayer.InventoryManager.TryGiveItemstack(bowlStack))
                        {
                            world.SpawnItemEntity(bowlStack, op.ActingPlayer.Entity.Pos.XYZ);
                        }
                    }
                    sourceSlot.MarkDirty();
                }

                return;
            }

            if (sourceSlot.Itemstack?.ItemAttributes?["contentItem2BlockCodes"].Exists == true)
            {
                return;
            }

            base.ActivateSlotLeftClick(sourceSlot, ref op);
        }