Example #1
0
        internal bool Construct(ItemSlot slot, IWorldAccessor world, BlockPos pos, IPlayer player)
        {
            Block belowBlock = world.BlockAccessor.GetBlock(pos.DownCopy());

            if (!belowBlock.CanAttachBlockAt(world.BlockAccessor, this, pos.DownCopy(), BlockFacing.UP) && (belowBlock != this || FillLevel(world.BlockAccessor, pos.DownCopy()) != 16))
            {
                return(false);
            }

            if (!world.BlockAccessor.GetBlock(pos).IsReplacableBy(this))
            {
                return(false);
            }

            world.BlockAccessor.SetBlock(BlockId, pos);

            BlockEntity be = world.BlockAccessor.GetBlockEntity(pos);

            if (be is BlockEntityPlatePile)
            {
                BlockEntityPlatePile pile = (BlockEntityPlatePile)be;
                int q = player.Entity.Controls.Sprint ? pile.BulkTakeQuantity : pile.DefaultTakeQuantity;

                pile.inventory[0].Itemstack           = (ItemStack)slot.Itemstack.Clone();
                pile.inventory[0].Itemstack.StackSize = Math.Min(slot.StackSize, q);

                if (player.WorldData.CurrentGameMode != EnumGameMode.Creative)
                {
                    slot.TakeOut(q);
                }

                pile.MarkDirty(true);

                world.PlaySoundAt(new AssetLocation("sounds/block/plate"), pos.X, pos.Y, pos.Z, player, false);
            }

            return(true);
        }
Example #2
0
        internal bool Construct(ItemSlot slot, IWorldAccessor world, BlockPos pos, IPlayer player)
        {
            Block belowBlock = world.BlockAccessor.GetBlock(pos.DownCopy());

            if (!belowBlock.SideSolid[BlockFacing.UP.Index] && (belowBlock != this || FillLevel(world.BlockAccessor, pos.DownCopy()) != 16))
            {
                return(false);
            }

            if (!world.BlockAccessor.GetBlock(pos).IsReplacableBy(this))
            {
                return(false);
            }

            world.BlockAccessor.SetBlock(BlockId, pos);

            BlockEntity be = world.BlockAccessor.GetBlockEntity(pos);

            if (be is BlockEntityPlatePile)
            {
                BlockEntityPlatePile pile = (BlockEntityPlatePile)be;
                pile.inventory[0].Itemstack           = (ItemStack)slot.Itemstack.Clone();
                pile.inventory[0].Itemstack.StackSize = 1;

                if (player.WorldData.CurrentGameMode != EnumGameMode.Creative)
                {
                    slot.TakeOut(1);
                }

                pile.MarkDirty(true);

                world.PlaySoundAt(new AssetLocation("sounds/block/ingot"), pos.X, pos.Y, pos.Z, player, false);
            }

            return(true);
        }